Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Rename the SQLiteModule class to SQLiteModuleNoop. Adjustments to method and parameter naming conventions. Initial implementation of xOpen virtual table method. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | virtualTables |
Files: | files | file ages | folders |
SHA1: |
f5c3afbfb10a2c7d972078ad7aa0f714 |
User & Date: | mistachkin 2013-06-07 02:45:01.809 |
Context
2013-06-07
| ||
08:32 | Some cleanup work. Implement the SQLiteValue helper class. check-in: 33b2470a68 user: mistachkin tags: virtualTables | |
02:45 | Rename the SQLiteModule class to SQLiteModuleNoop. Adjustments to method and parameter naming conventions. Initial implementation of xOpen virtual table method. check-in: f5c3afbfb1 user: mistachkin tags: virtualTables | |
00:56 | Implement the xDisconnect and xDestroy virtual table methods. check-in: f19e7df898 user: mistachkin tags: virtualTables | |
Changes
Changes to System.Data.SQLite/SQLiteModuleBase.cs.
︙ | ︙ | |||
66 67 68 69 70 71 72 | double estimatedCost; /* Estimated cost of using this index */ } /////////////////////////////////////////////////////////////////////// public class SQLiteVirtualTableCursor { | | | | | | | | | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | double estimatedCost; /* Estimated cost of using this index */ } /////////////////////////////////////////////////////////////////////// public class SQLiteVirtualTableCursor { internal SQLiteModuleBase.UnsafeNativeMethods2.sqlite3_vtab_cursor cursor; } [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int xFunc( IntPtr pContext, int argc, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] IntPtr[] argv ); public interface ISQLiteNativeModule { SQLiteErrorCode xCreate(IntPtr pDb, IntPtr pAux, int argc, ref IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError); SQLiteErrorCode xConnect(IntPtr pDb, IntPtr pAux, int argc, ref IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError); SQLiteErrorCode xBestIndex(IntPtr pVtab, IntPtr index); SQLiteErrorCode xDisconnect(IntPtr pVtab); SQLiteErrorCode xDestroy(IntPtr pVtab); SQLiteErrorCode xOpen(IntPtr pVtab, ref IntPtr pCursor); SQLiteErrorCode xClose(IntPtr pCursor); SQLiteErrorCode xFilter(IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, IntPtr[] argv); SQLiteErrorCode xNext(IntPtr pCursor); SQLiteErrorCode xEof(IntPtr pCursor); SQLiteErrorCode xColumn(IntPtr pCursor, IntPtr pContext, int index); SQLiteErrorCode xRowId(IntPtr pCursor, ref long rowId); SQLiteErrorCode xUpdate(IntPtr pVtab, int nData, ref IntPtr apData, ref long rowId); SQLiteErrorCode xBegin(IntPtr pVtab); SQLiteErrorCode xSync(IntPtr pVtab); SQLiteErrorCode xCommit(IntPtr pVtab); SQLiteErrorCode xRollback(IntPtr pVtab); SQLiteErrorCode xFindFunction(IntPtr pVtab, int nArg, IntPtr zName, ref xFunc pxFunc, ref IntPtr ppArg); SQLiteErrorCode xRename(IntPtr pVtab, IntPtr zNew); |
︙ | ︙ | |||
284 285 286 287 288 289 290 | IntPtr pVtab ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xOpen( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pVtab, | | | | | | | | | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | IntPtr pVtab ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xOpen( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pVtab, ref IntPtr pCursor ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xClose( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pCursor ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xFilter( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, IntPtr[] argv ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xNext( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pCursor ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xEof( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pCursor ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xColumn( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pCursor, IntPtr pContext, int index ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xRowId( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pCursor, ref long rowId ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xUpdate( [MarshalAs(UnmanagedType.LPStruct)] IntPtr pVtab, |
︙ | ︙ | |||
592 593 594 595 596 597 598 | { } #endregion /////////////////////////////////////////////////////////////////////// #region Protected Members | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | { } #endregion /////////////////////////////////////////////////////////////////////// #region Protected Members protected virtual IntPtr AllocateTable() { int size = Marshal.SizeOf(typeof( UnsafeNativeMethods2.sqlite3_vtab)); return Allocate(size); } /////////////////////////////////////////////////////////////////////// protected virtual void FreeTable(IntPtr pVtab) { Free(pVtab); } /////////////////////////////////////////////////////////////////////// protected virtual IntPtr AllocateCursor() { int size = Marshal.SizeOf(typeof( UnsafeNativeMethods2.sqlite3_vtab_cursor)); return Allocate(size); } /////////////////////////////////////////////////////////////////////// protected virtual IntPtr GetTableFromCursor( IntPtr pCursor ) { if (pCursor == IntPtr.Zero) return IntPtr.Zero; return Marshal.ReadIntPtr(pCursor); } /////////////////////////////////////////////////////////////////////// protected virtual SQLiteVirtualTableCursor MarshalCursorFromIntPtr( IntPtr pCursor ) { if (pCursor == IntPtr.Zero) return null; SQLiteVirtualTableCursor result = new SQLiteVirtualTableCursor(); Marshal.PtrToStructure(pCursor, result.cursor); return result; } /////////////////////////////////////////////////////////////////////// protected virtual IntPtr MarshalCursorToIntPtr( SQLiteVirtualTableCursor cursor ) { if (cursor == null) return IntPtr.Zero; IntPtr result = IntPtr.Zero; bool success = false; try { result = AllocateCursor(); if (result != IntPtr.Zero) { Marshal.StructureToPtr(cursor.cursor, result, false); success = true; } } finally { if (!success && (result != IntPtr.Zero)) { FreeCursor(result); result = IntPtr.Zero; } } return result; } /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// protected virtual void FreeCursor(IntPtr pCursor) { Free(pCursor); } /////////////////////////////////////////////////////////////////////// protected virtual SQLiteErrorCode DeclareTable( SQLiteConnection connection, string sql, ref string error ) { if (connection == null) { |
︙ | ︙ | |||
631 632 633 634 635 636 637 638 639 640 641 642 643 644 | { error = "connection has invalid handle"; return SQLiteErrorCode.Error; } return sqliteBase.DeclareVirtualTable(this, sql, ref error); } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeModule Members public SQLiteErrorCode xCreate( IntPtr pDb, | > > > > > > > > > > > > > > > > > > > > > > > > > | 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | { error = "connection has invalid handle"; return SQLiteErrorCode.Error; } return sqliteBase.DeclareVirtualTable(this, sql, ref error); } /////////////////////////////////////////////////////////////////////// protected virtual bool SetTableError( IntPtr pVtab, string error ) { if (pVtab == IntPtr.Zero) return false; int offset = Marshal.SizeOf(typeof( UnsafeNativeMethods2.sqlite3_module)) + sizeof(int); IntPtr pError = Marshal.ReadIntPtr(pVtab, offset); if (pError != IntPtr.Zero) { Free(pError); pError = IntPtr.Zero; Marshal.WriteIntPtr(pVtab, offset, pError); } Marshal.WriteIntPtr(pVtab, offset, Utf8IntPtrFromString(error)); return true; } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeModule Members public SQLiteErrorCode xCreate( IntPtr pDb, |
︙ | ︙ | |||
656 657 658 659 660 661 662 | { string error = null; if (Create(connection, pAux, StringArrayFromUtf8IntPtrArray(argv), ref error) == SQLiteErrorCode.Ok) { | | | 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | { string error = null; if (Create(connection, pAux, StringArrayFromUtf8IntPtrArray(argv), ref error) == SQLiteErrorCode.Ok) { pVtab = AllocateTable(); return SQLiteErrorCode.Ok; } else { pError = Utf8IntPtrFromString(error); } } |
︙ | ︙ | |||
695 696 697 698 699 700 701 | { string error = null; if (Connect(connection, pAux, StringArrayFromUtf8IntPtrArray(argv), ref error) == SQLiteErrorCode.Ok) { | | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | { string error = null; if (Connect(connection, pAux, StringArrayFromUtf8IntPtrArray(argv), ref error) == SQLiteErrorCode.Ok) { pVtab = AllocateTable(); return SQLiteErrorCode.Ok; } else { pError = Utf8IntPtrFromString(error); } } |
︙ | ︙ | |||
754 755 756 757 758 759 760 | catch { // do nothing. } } finally { | | | 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 | catch { // do nothing. } } finally { FreeTable(pVtab); } return SQLiteErrorCode.Error; } /////////////////////////////////////////////////////////////////////// |
︙ | ︙ | |||
792 793 794 795 796 797 798 | catch { // do nothing. } } finally { | | | > > > > > > > > > | > > > > > > > > > > > > > > > > > | > > > > > > > > > > | > > > > > > > > > > > | | | | | | | 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 | catch { // do nothing. } } finally { FreeTable(pVtab); } return SQLiteErrorCode.Error; } /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xOpen( IntPtr pVtab, ref IntPtr pCursor ) { try { SQLiteVirtualTableCursor cursor = null; if (Open(ref cursor) == SQLiteErrorCode.Ok) { if (cursor != null) { pCursor = MarshalCursorToIntPtr(cursor); return SQLiteErrorCode.Ok; } else { SetTableError(pVtab, "no cursor was created"); } } } catch (Exception e) /* NOTE: Must catch ALL. */ { SetTableError(pVtab, e.ToString()); } finally { FreeCursor(pCursor); } return SQLiteErrorCode.Error; } /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xClose( IntPtr pCursor ) { IntPtr pVtab = IntPtr.Zero; try { pVtab = GetTableFromCursor(pCursor); SQLiteVirtualTableCursor cursor = MarshalCursorFromIntPtr( pCursor); if (Close(cursor) == SQLiteErrorCode.Ok) return SQLiteErrorCode.Ok; } catch (Exception e) /* NOTE: Must catch ALL. */ { SetTableError(pVtab, e.ToString()); } finally { FreeCursor(pCursor); } return SQLiteErrorCode.Error; } /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xFilter( IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, IntPtr[] argv ) { return SQLiteErrorCode.Ok; } /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xNext( IntPtr pCursor ) { return SQLiteErrorCode.Ok; } /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xEof( IntPtr pCursor ) { return SQLiteErrorCode.Ok; } /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xColumn( IntPtr pCursor, IntPtr pContext, int index ) { return SQLiteErrorCode.Ok; } /////////////////////////////////////////////////////////////////////// public SQLiteErrorCode xRowId( IntPtr pCursor, ref long rowId ) { return SQLiteErrorCode.Ok; } /////////////////////////////////////////////////////////////////////// |
︙ | ︙ |
Name change from System.Data.SQLite/SQLiteModule.cs to System.Data.SQLite/SQLiteModuleNoop.cs.
1 2 3 4 5 6 7 8 9 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Joe Mistachkin (joe@mistachkin.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { | | | | 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 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Joe Mistachkin (joe@mistachkin.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { public class SQLiteModuleNoop : SQLiteModuleBase { #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteModuleNoop).Name); #endif } /////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { |
︙ | ︙ | |||
44 45 46 47 48 49 50 | finally { base.Dispose(disposing); } } #endregion | > > > | > > > > > > > > > > > > > > > > > > > | > > < < < < > > > > > | > > > > | > > > > | > > > > > > > | > > > > | > > > > | > > > > > > | > > > > > | > > > > > > > > > > > > > | > > > > > > | > > > > | > > > > | > > > > | > > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 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 | finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteManagedModule Members public override SQLiteErrorCode Create( SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Connect( SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode BestIndex( ref SQLiteIndex index ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Disconnect() { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Destroy() { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Open( ref SQLiteVirtualTableCursor cursor ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Close( SQLiteVirtualTableCursor cursor ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Filter( SQLiteVirtualTableCursor cursor, int idxNum, string idxStr, SQLiteValue[] argv ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Next( SQLiteVirtualTableCursor cursor ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Eof( SQLiteVirtualTableCursor cursor ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Column( SQLiteVirtualTableCursor cursor, SQLiteContext context, int index ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode RowId( SQLiteVirtualTableCursor cursor, ref long rowId ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Update( SQLiteValue[] values, ref long rowId ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Begin() { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Sync() { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Commit() { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Rollback() { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode FindFunction( string zName, ref SQLiteFunction function, object[] args ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Rename( string zNew ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Savepoint( int iSavepoint ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode Release( int iSavepoint ) { throw new NotImplementedException(); } /////////////////////////////////////////////////////////////////////// public override SQLiteErrorCode RollbackTo( int iSavepoint ) { throw new NotImplementedException(); } #endregion } } |
Changes to System.Data.SQLite/System.Data.SQLite.Files.targets.
︙ | ︙ | |||
64 65 66 67 68 69 70 | ****************************************************************************** ** Core Files (Full Framework) ** ****************************************************************************** --> <ItemGroup Condition="'$(IsCompactFramework)' == 'false'"> <Compile Include="SQLiteEnlistment.cs" /> | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | ****************************************************************************** ** Core Files (Full Framework) ** ****************************************************************************** --> <ItemGroup Condition="'$(IsCompactFramework)' == 'false'"> <Compile Include="SQLiteEnlistment.cs" /> <Compile Include="SQLiteModuleBase.cs" /> <Compile Include="SQLiteModuleNoop.cs" /> <Compile Condition="'$(NetFx35)' != 'false' Or '$(NetFx40)' != 'false' Or '$(NetFx45)' != 'false'" Include="LINQ\SQLiteConnection_Linq.cs"> <SubType>Component</SubType> </Compile> <Compile Condition="'$(NetFx35)' != 'false' Or |
︙ | ︙ |