Skip to content

Commit

Permalink
add sqlite3_prepare_v3(). #257
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsink committed Mar 4, 2019
1 parent cc76614 commit bdd3e2e
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SQLitePCLRaw.core/isqlite3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public interface ISQLite3Provider
string sqlite3_errstr(int rc); /* 3.7.15+ */

int sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stmt, out string remain);
int sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stmt, out string remain);
int sqlite3_step(sqlite3_stmt stmt);
int sqlite3_finalize(IntPtr stmt);
int sqlite3_reset(sqlite3_stmt stmt);
Expand Down
18 changes: 18 additions & 0 deletions src/SQLitePCLRaw.core/raw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ static public void FreezeProvider(bool b = true)
public const int SQLITE_OPEN_PRIVATECACHE = 0x00040000; /* Ok for sqlite3_open_v2() */
public const int SQLITE_OPEN_WAL = 0x00080000; /* VFS only */

public const int SQLITE_PREPARE_PERSISTENT = 0x01;
public const int SQLITE_PREPARE_NORMALIZE = 0x02;
public const int SQLITE_PREPARE_NO_VTAB = 0x04;

public const int SQLITE_INTEGER = 1;
public const int SQLITE_FLOAT = 2;
public const int SQLITE_TEXT = 3;
Expand Down Expand Up @@ -528,6 +532,20 @@ static public int sqlite3_prepare_v2(sqlite3 db, string sql, out sqlite3_stmt st
return rc;
}

static public int sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out sqlite3_stmt stmt)
{
string tail;
return sqlite3_prepare_v3(db, sql, flags, out stmt, out tail);
}

static public int sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out sqlite3_stmt stmt, out string tail)
{
IntPtr p;
int rc = _imp.sqlite3_prepare_v3(db, sql, flags, out p, out tail);
stmt = sqlite3_stmt.From(p, db);
return rc;
}

static public int sqlite3_exec(sqlite3 db, string sql, delegate_exec callback, object user_data, out string errMsg)
{
return _imp.sqlite3_exec(db, sql, callback, user_data, out errMsg);
Expand Down
28 changes: 28 additions & 0 deletions src/SQLitePCLRaw.provider.dynamic/Generated/provider_cdecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,29 @@ int ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stm,
return rc;
}

int ISQLite3Provider.sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stm, out string remain)
{
var ba_sql = util.to_utf8(sql);
GCHandle pinned_sql = GCHandle.Alloc(ba_sql, GCHandleType.Pinned);
IntPtr ptr_sql = pinned_sql.AddrOfPinnedObject();
IntPtr tail;
int rc = NativeMethods.sqlite3_prepare_v3(db, ptr_sql, -1, flags, out stm, out tail);
if (tail == IntPtr.Zero)
{
remain = null;
}
else
{
remain = util.from_utf8(tail);
if (remain.Length == 0)
{
remain = null;
}
}
pinned_sql.Free();
return rc;
}

int ISQLite3Provider.sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg)
{
return NativeMethods.sqlite3_db_status(db, op, out current, out highest, resetFlg);
Expand Down Expand Up @@ -1319,6 +1342,7 @@ static public void Setup(IGetFunctionPointer gf)
sqlite3_db_filename = (MyDelegateTypes.sqlite3_db_filename) Load(gf, typeof(MyDelegateTypes.sqlite3_db_filename));
sqlite3_prepare = (MyDelegateTypes.sqlite3_prepare) Load(gf, typeof(MyDelegateTypes.sqlite3_prepare));
sqlite3_prepare_v2 = (MyDelegateTypes.sqlite3_prepare_v2) Load(gf, typeof(MyDelegateTypes.sqlite3_prepare_v2));
sqlite3_prepare_v3 = (MyDelegateTypes.sqlite3_prepare_v3) Load(gf, typeof(MyDelegateTypes.sqlite3_prepare_v3));
sqlite3_db_status = (MyDelegateTypes.sqlite3_db_status) Load(gf, typeof(MyDelegateTypes.sqlite3_db_status));
sqlite3_complete = (MyDelegateTypes.sqlite3_complete) Load(gf, typeof(MyDelegateTypes.sqlite3_complete));
sqlite3_compileoption_used = (MyDelegateTypes.sqlite3_compileoption_used) Load(gf, typeof(MyDelegateTypes.sqlite3_compileoption_used));
Expand Down Expand Up @@ -1448,6 +1472,7 @@ static public void Setup(IGetFunctionPointer gf)
public static MyDelegateTypes.sqlite3_db_filename sqlite3_db_filename;
public static MyDelegateTypes.sqlite3_prepare sqlite3_prepare;
public static MyDelegateTypes.sqlite3_prepare_v2 sqlite3_prepare_v2;
public static MyDelegateTypes.sqlite3_prepare_v3 sqlite3_prepare_v3;
public static MyDelegateTypes.sqlite3_db_status sqlite3_db_status;
public static MyDelegateTypes.sqlite3_complete sqlite3_complete;
public static MyDelegateTypes.sqlite3_compileoption_used sqlite3_compileoption_used;
Expand Down Expand Up @@ -1661,6 +1686,9 @@ static class MyDelegateTypes
[UnmanagedFunctionPointer(CALLING_CONVENTION)]
public delegate int sqlite3_prepare_v2(sqlite3 db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);

[UnmanagedFunctionPointer(CALLING_CONVENTION)]
public delegate int sqlite3_prepare_v3(sqlite3 db, IntPtr pSql, int nBytes, uint flags, out IntPtr stmt, out IntPtr ptrRemain);

[UnmanagedFunctionPointer(CALLING_CONVENTION)]
public delegate int sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg);

Expand Down
28 changes: 28 additions & 0 deletions src/SQLitePCLRaw.provider.dynamic/Generated/provider_stdcall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,29 @@ int ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stm,
return rc;
}

int ISQLite3Provider.sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stm, out string remain)
{
var ba_sql = util.to_utf8(sql);
GCHandle pinned_sql = GCHandle.Alloc(ba_sql, GCHandleType.Pinned);
IntPtr ptr_sql = pinned_sql.AddrOfPinnedObject();
IntPtr tail;
int rc = NativeMethods.sqlite3_prepare_v3(db, ptr_sql, -1, flags, out stm, out tail);
if (tail == IntPtr.Zero)
{
remain = null;
}
else
{
remain = util.from_utf8(tail);
if (remain.Length == 0)
{
remain = null;
}
}
pinned_sql.Free();
return rc;
}

int ISQLite3Provider.sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg)
{
return NativeMethods.sqlite3_db_status(db, op, out current, out highest, resetFlg);
Expand Down Expand Up @@ -1319,6 +1342,7 @@ static public void Setup(IGetFunctionPointer gf)
sqlite3_db_filename = (MyDelegateTypes.sqlite3_db_filename) Load(gf, typeof(MyDelegateTypes.sqlite3_db_filename));
sqlite3_prepare = (MyDelegateTypes.sqlite3_prepare) Load(gf, typeof(MyDelegateTypes.sqlite3_prepare));
sqlite3_prepare_v2 = (MyDelegateTypes.sqlite3_prepare_v2) Load(gf, typeof(MyDelegateTypes.sqlite3_prepare_v2));
sqlite3_prepare_v3 = (MyDelegateTypes.sqlite3_prepare_v3) Load(gf, typeof(MyDelegateTypes.sqlite3_prepare_v3));
sqlite3_db_status = (MyDelegateTypes.sqlite3_db_status) Load(gf, typeof(MyDelegateTypes.sqlite3_db_status));
sqlite3_complete = (MyDelegateTypes.sqlite3_complete) Load(gf, typeof(MyDelegateTypes.sqlite3_complete));
sqlite3_compileoption_used = (MyDelegateTypes.sqlite3_compileoption_used) Load(gf, typeof(MyDelegateTypes.sqlite3_compileoption_used));
Expand Down Expand Up @@ -1448,6 +1472,7 @@ static public void Setup(IGetFunctionPointer gf)
public static MyDelegateTypes.sqlite3_db_filename sqlite3_db_filename;
public static MyDelegateTypes.sqlite3_prepare sqlite3_prepare;
public static MyDelegateTypes.sqlite3_prepare_v2 sqlite3_prepare_v2;
public static MyDelegateTypes.sqlite3_prepare_v3 sqlite3_prepare_v3;
public static MyDelegateTypes.sqlite3_db_status sqlite3_db_status;
public static MyDelegateTypes.sqlite3_complete sqlite3_complete;
public static MyDelegateTypes.sqlite3_compileoption_used sqlite3_compileoption_used;
Expand Down Expand Up @@ -1661,6 +1686,9 @@ static class MyDelegateTypes
[UnmanagedFunctionPointer(CALLING_CONVENTION)]
public delegate int sqlite3_prepare_v2(sqlite3 db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);

[UnmanagedFunctionPointer(CALLING_CONVENTION)]
public delegate int sqlite3_prepare_v3(sqlite3 db, IntPtr pSql, int nBytes, uint flags, out IntPtr stmt, out IntPtr ptrRemain);

[UnmanagedFunctionPointer(CALLING_CONVENTION)]
public delegate int sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ int ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stm,
return rc;
}

int ISQLite3Provider.sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stm, out string remain)
{
var ba_sql = util.to_utf8(sql);
GCHandle pinned_sql = GCHandle.Alloc(ba_sql, GCHandleType.Pinned);
IntPtr ptr_sql = pinned_sql.AddrOfPinnedObject();
IntPtr tail;
int rc = NativeMethods.sqlite3_prepare_v3(db, ptr_sql, -1, flags, out stm, out tail);
if (tail == IntPtr.Zero)
{
remain = null;
}
else
{
remain = util.from_utf8(tail);
if (remain.Length == 0)
{
remain = null;
}
}
pinned_sql.Free();
return rc;
}

int ISQLite3Provider.sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg)
{
return NativeMethods.sqlite3_db_status(db, op, out current, out highest, resetFlg);
Expand Down Expand Up @@ -1328,6 +1351,9 @@ static class NativeMethods
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v2(sqlite3 db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v3(sqlite3 db, IntPtr pSql, int nBytes, uint flags, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ int ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stm,
return rc;
}

int ISQLite3Provider.sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stm, out string remain)
{
var ba_sql = util.to_utf8(sql);
GCHandle pinned_sql = GCHandle.Alloc(ba_sql, GCHandleType.Pinned);
IntPtr ptr_sql = pinned_sql.AddrOfPinnedObject();
IntPtr tail;
int rc = NativeMethods.sqlite3_prepare_v3(db, ptr_sql, -1, flags, out stm, out tail);
if (tail == IntPtr.Zero)
{
remain = null;
}
else
{
remain = util.from_utf8(tail);
if (remain.Length == 0)
{
remain = null;
}
}
pinned_sql.Free();
return rc;
}

int ISQLite3Provider.sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg)
{
return NativeMethods.sqlite3_db_status(db, op, out current, out highest, resetFlg);
Expand Down Expand Up @@ -1328,6 +1351,9 @@ static class NativeMethods
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v2(sqlite3 db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v3(sqlite3 db, IntPtr pSql, int nBytes, uint flags, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg);

Expand Down
26 changes: 26 additions & 0 deletions src/SQLitePCLRaw.provider.internal/Generated/provider_internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ int ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stm,
return rc;
}

int ISQLite3Provider.sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stm, out string remain)
{
var ba_sql = util.to_utf8(sql);
GCHandle pinned_sql = GCHandle.Alloc(ba_sql, GCHandleType.Pinned);
IntPtr ptr_sql = pinned_sql.AddrOfPinnedObject();
IntPtr tail;
int rc = NativeMethods.sqlite3_prepare_v3(db, ptr_sql, -1, flags, out stm, out tail);
if (tail == IntPtr.Zero)
{
remain = null;
}
else
{
remain = util.from_utf8(tail);
if (remain.Length == 0)
{
remain = null;
}
}
pinned_sql.Free();
return rc;
}

int ISQLite3Provider.sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg)
{
return NativeMethods.sqlite3_db_status(db, op, out current, out highest, resetFlg);
Expand Down Expand Up @@ -1328,6 +1351,9 @@ static class NativeMethods
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v2(sqlite3 db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v3(sqlite3 db, IntPtr pSql, int nBytes, uint flags, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ int ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stm,
return rc;
}

int ISQLite3Provider.sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stm, out string remain)
{
var ba_sql = util.to_utf8(sql);
GCHandle pinned_sql = GCHandle.Alloc(ba_sql, GCHandleType.Pinned);
IntPtr ptr_sql = pinned_sql.AddrOfPinnedObject();
IntPtr tail;
int rc = NativeMethods.sqlite3_prepare_v3(db, ptr_sql, -1, flags, out stm, out tail);
if (tail == IntPtr.Zero)
{
remain = null;
}
else
{
remain = util.from_utf8(tail);
if (remain.Length == 0)
{
remain = null;
}
}
pinned_sql.Free();
return rc;
}

int ISQLite3Provider.sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg)
{
return NativeMethods.sqlite3_db_status(db, op, out current, out highest, resetFlg);
Expand Down Expand Up @@ -1328,6 +1351,9 @@ static class NativeMethods
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v2(sqlite3 db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v3(sqlite3 db, IntPtr pSql, int nBytes, uint flags, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg);

Expand Down
26 changes: 26 additions & 0 deletions src/SQLitePCLRaw.provider.sqlite3/Generated/provider_sqlite3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ int ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stm,
return rc;
}

int ISQLite3Provider.sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stm, out string remain)
{
var ba_sql = util.to_utf8(sql);
GCHandle pinned_sql = GCHandle.Alloc(ba_sql, GCHandleType.Pinned);
IntPtr ptr_sql = pinned_sql.AddrOfPinnedObject();
IntPtr tail;
int rc = NativeMethods.sqlite3_prepare_v3(db, ptr_sql, -1, flags, out stm, out tail);
if (tail == IntPtr.Zero)
{
remain = null;
}
else
{
remain = util.from_utf8(tail);
if (remain.Length == 0)
{
remain = null;
}
}
pinned_sql.Free();
return rc;
}

int ISQLite3Provider.sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg)
{
return NativeMethods.sqlite3_db_status(db, op, out current, out highest, resetFlg);
Expand Down Expand Up @@ -1328,6 +1351,9 @@ static class NativeMethods
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v2(sqlite3 db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v3(sqlite3 db, IntPtr pSql, int nBytes, uint flags, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ int ISQLite3Provider.sqlite3_prepare_v2(sqlite3 db, string sql, out IntPtr stm,
return rc;
}

int ISQLite3Provider.sqlite3_prepare_v3(sqlite3 db, string sql, uint flags, out IntPtr stm, out string remain)
{
var ba_sql = util.to_utf8(sql);
GCHandle pinned_sql = GCHandle.Alloc(ba_sql, GCHandleType.Pinned);
IntPtr ptr_sql = pinned_sql.AddrOfPinnedObject();
IntPtr tail;
int rc = NativeMethods.sqlite3_prepare_v3(db, ptr_sql, -1, flags, out stm, out tail);
if (tail == IntPtr.Zero)
{
remain = null;
}
else
{
remain = util.from_utf8(tail);
if (remain.Length == 0)
{
remain = null;
}
}
pinned_sql.Free();
return rc;
}

int ISQLite3Provider.sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg)
{
return NativeMethods.sqlite3_db_status(db, op, out current, out highest, resetFlg);
Expand Down Expand Up @@ -1328,6 +1351,9 @@ static class NativeMethods
[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v2(sqlite3 db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_prepare_v3(sqlite3 db, IntPtr pSql, int nBytes, uint flags, out IntPtr stmt, out IntPtr ptrRemain);

[DllImport(SQLITE_DLL, ExactSpelling=true, CallingConvention = CALLING_CONVENTION)]
public static extern int sqlite3_db_status(sqlite3 db, int op, out int current, out int highest, int resetFlg);

Expand Down
Loading

0 comments on commit bdd3e2e

Please sign in to comment.