System.Data.SQLite
Check-in [091ead1daf]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Keep track of whether the DeclareVirtualTable method has been called by a virtual table module.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | virtualTables
Files: files | file ages | folders
SHA1: 091ead1daf09d81e707d449366b4800b2a4d57db
User & Date: mistachkin 2013-06-07 00:28:18
Context
2013-06-07
00:56
Implement the xDisconnect and xDestroy virtual table methods. check-in: f19e7df898 user: mistachkin tags: virtualTables
00:28
Keep track of whether the DeclareVirtualTable method has been called by a virtual table module. check-in: 091ead1daf user: mistachkin tags: virtualTables
00:04
Add initial marshalling infrastructure and start implementing the xCreate and xConnect virtual table methods. check-in: bf5505be7a user: mistachkin tags: virtualTables
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLite3.cs.

1510
1511
1512
1513
1514
1515
1516




1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528




1529
1530
1531



1532
1533
1534
1535
1536
1537
1538
      return UnsafeNativeMethods.sqlite3_aggregate_context(context, 1);
    }

    /// <summary>
    /// Calls the native SQLite core library in order to declare a virtual table
    /// in response to a call into the xCreate or xConnect virtual table methods.
    /// </summary>




    /// <param name="strSql">
    /// The string containing the SQL statement describing the virtual table to
    /// be declared.
    /// </param>
    /// <param name="error">
    /// Upon success, the contents of this parameter are undefined.  Upon failure,
    /// it should contain an appropriate error message.
    /// </param>
    /// <returns>
    /// A standard SQLite return code.
    /// </returns>
    internal override SQLiteErrorCode DeclareVirtualTable(string strSql, ref string error)




    {
        SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_declare_vtab(
            _sql, SQLiteModuleBase.Utf8IntPtrFromString(strSql));




        if (n != SQLiteErrorCode.Ok) error = GetLastError();

        return n;
    }

    /// <summary>







>
>
>
>











|
>
>
>
>



>
>
>







1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
      return UnsafeNativeMethods.sqlite3_aggregate_context(context, 1);
    }

    /// <summary>
    /// Calls the native SQLite core library in order to declare a virtual table
    /// in response to a call into the xCreate or xConnect virtual table methods.
    /// </summary>
    /// <param name="module">
    /// The virtual table module that is to be responsible for the virtual table
    /// being declared.
    /// </param>
    /// <param name="strSql">
    /// The string containing the SQL statement describing the virtual table to
    /// be declared.
    /// </param>
    /// <param name="error">
    /// Upon success, the contents of this parameter are undefined.  Upon failure,
    /// it should contain an appropriate error message.
    /// </param>
    /// <returns>
    /// A standard SQLite return code.
    /// </returns>
    internal override SQLiteErrorCode DeclareVirtualTable(
        SQLiteModuleBase module,
        string strSql,
        ref string error
        )
    {
        SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_declare_vtab(
            _sql, SQLiteModuleBase.Utf8IntPtrFromString(strSql));

        if ((n == SQLiteErrorCode.Ok) && (module != null))
            module.Declared = true;

        if (n != SQLiteErrorCode.Ok) error = GetLastError();

        return n;
    }

    /// <summary>

Changes to System.Data.SQLite/SQLiteBase.cs.

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
    internal abstract void ReturnNull(IntPtr context);
    internal abstract void ReturnText(IntPtr context, string value);

    /// <summary>
    /// Calls the native SQLite core library in order to declare a virtual table
    /// in response to a call into the xCreate or xConnect virtual table methods.
    /// </summary>




    /// <param name="strSql">
    /// The string containing the SQL statement describing the virtual table to
    /// be declared.
    /// </param>
    /// <param name="error">
    /// Upon success, the contents of this parameter are undefined.  Upon failure,
    /// it should contain an appropriate error message.
    /// </param>
    /// <returns>
    /// A standard SQLite return code.
    /// </returns>
    internal abstract SQLiteErrorCode DeclareVirtualTable(string strSql, ref string error);

    /// <summary>
    /// Enables or disabled extension loading by SQLite.
    /// </summary>
    /// <param name="bOnOff">
    /// True to enable loading of extensions, false to disable.
    /// </param>







>
>
>
>











|







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
    internal abstract void ReturnNull(IntPtr context);
    internal abstract void ReturnText(IntPtr context, string value);

    /// <summary>
    /// Calls the native SQLite core library in order to declare a virtual table
    /// in response to a call into the xCreate or xConnect virtual table methods.
    /// </summary>
    /// <param name="module">
    /// The virtual table module that is to be responsible for the virtual table
    /// being declared.
    /// </param>
    /// <param name="strSql">
    /// The string containing the SQL statement describing the virtual table to
    /// be declared.
    /// </param>
    /// <param name="error">
    /// Upon success, the contents of this parameter are undefined.  Upon failure,
    /// it should contain an appropriate error message.
    /// </param>
    /// <returns>
    /// A standard SQLite return code.
    /// </returns>
    internal abstract SQLiteErrorCode DeclareVirtualTable(SQLiteModuleBase module, string strSql, ref string error);

    /// <summary>
    /// Enables or disabled extension loading by SQLite.
    /// </summary>
    /// <param name="bOnOff">
    /// True to enable loading of extensions, false to disable.
    /// </param>

Changes to System.Data.SQLite/SQLiteModuleBase.cs.

104
105
106
107
108
109
110


111
112
113
114
115
116
117
...
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
...
654
655
656
657
658
659
660

661
662
663
664
665
666
667
...
692
693
694
695
696
697
698

699
700
701
702
703
704
705
...
911
912
913
914
915
916
917









918
919
920
921
922
923
924
        SQLiteErrorCode xSavepoint(IntPtr pVtab, int iSavepoint);
        SQLiteErrorCode xRelease(IntPtr pVtab, int iSavepoint);
        SQLiteErrorCode xRollbackTo(IntPtr pVtab, int iSavepoint);
    }

    public interface ISQLiteManagedModule
    {


        SQLiteErrorCode Create(SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error);
        SQLiteErrorCode Connect(SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error);
        SQLiteErrorCode BestIndex(ref SQLiteIndex index);
        SQLiteErrorCode Disconnect();
        SQLiteErrorCode Destroy();
        SQLiteErrorCode Open(ref SQLiteVirtualTableCursor cursor);
        SQLiteErrorCode Close(SQLiteVirtualTableCursor cursor);
................................................................................

            if (sqliteBase == null)
            {
                error = "connection has invalid handle";
                return SQLiteErrorCode.Error;
            }

            return sqliteBase.DeclareVirtualTable(sql, ref error);
        }
        #endregion

        ///////////////////////////////////////////////////////////////////////

        #region ISQLiteNativeModule Members
        public SQLiteErrorCode xCreate(
................................................................................
                    string error = null;

                    if (Create(connection, pAux,
                            StringArrayFromUtf8IntPtrArray(argv),
                            ref error) == SQLiteErrorCode.Ok)
                    {
                        pVtab = AllocateVirtualTable();

                    }
                    else
                    {
                        pError = Utf8IntPtrFromString(error);
                    }
                }
            }
................................................................................
                    string error = null;

                    if (Connect(connection, pAux,
                            StringArrayFromUtf8IntPtrArray(argv),
                            ref error) == SQLiteErrorCode.Ok)
                    {
                        pVtab = AllocateVirtualTable();

                    }
                    else
                    {
                        pError = Utf8IntPtrFromString(error);
                    }
                }
            }
................................................................................
            return SQLiteErrorCode.Ok;
        }
        #endregion

        ///////////////////////////////////////////////////////////////////////

        #region ISQLiteManagedModule Members









        public abstract SQLiteErrorCode Create(
            SQLiteConnection connection,
            IntPtr pClientData,
            string[] argv,
            ref string error
            );








>
>







 







|







 







>







 







>







 







>
>
>
>
>
>
>
>
>







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
...
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
...
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
...
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
...
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
        SQLiteErrorCode xSavepoint(IntPtr pVtab, int iSavepoint);
        SQLiteErrorCode xRelease(IntPtr pVtab, int iSavepoint);
        SQLiteErrorCode xRollbackTo(IntPtr pVtab, int iSavepoint);
    }

    public interface ISQLiteManagedModule
    {
        bool Declared { get; }

        SQLiteErrorCode Create(SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error);
        SQLiteErrorCode Connect(SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error);
        SQLiteErrorCode BestIndex(ref SQLiteIndex index);
        SQLiteErrorCode Disconnect();
        SQLiteErrorCode Destroy();
        SQLiteErrorCode Open(ref SQLiteVirtualTableCursor cursor);
        SQLiteErrorCode Close(SQLiteVirtualTableCursor cursor);
................................................................................

            if (sqliteBase == null)
            {
                error = "connection has invalid handle";
                return SQLiteErrorCode.Error;
            }

            return sqliteBase.DeclareVirtualTable(this, sql, ref error);
        }
        #endregion

        ///////////////////////////////////////////////////////////////////////

        #region ISQLiteNativeModule Members
        public SQLiteErrorCode xCreate(
................................................................................
                    string error = null;

                    if (Create(connection, pAux,
                            StringArrayFromUtf8IntPtrArray(argv),
                            ref error) == SQLiteErrorCode.Ok)
                    {
                        pVtab = AllocateVirtualTable();
                        return SQLiteErrorCode.Ok;
                    }
                    else
                    {
                        pError = Utf8IntPtrFromString(error);
                    }
                }
            }
................................................................................
                    string error = null;

                    if (Connect(connection, pAux,
                            StringArrayFromUtf8IntPtrArray(argv),
                            ref error) == SQLiteErrorCode.Ok)
                    {
                        pVtab = AllocateVirtualTable();
                        return SQLiteErrorCode.Ok;
                    }
                    else
                    {
                        pError = Utf8IntPtrFromString(error);
                    }
                }
            }
................................................................................
            return SQLiteErrorCode.Ok;
        }
        #endregion

        ///////////////////////////////////////////////////////////////////////

        #region ISQLiteManagedModule Members
        private bool declared;
        public bool Declared
        {
            get { return declared; }
            internal set { declared = value; }
        }

        ///////////////////////////////////////////////////////////////////////

        public abstract SQLiteErrorCode Create(
            SQLiteConnection connection,
            IntPtr pClientData,
            string[] argv,
            ref string error
            );