Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sqlite3_stmt_isexplain #328

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SQLitePCLRaw.core/isqlite3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public interface ISQLite3Provider
int sqlite3_value_type(IntPtr p);
utf8z sqlite3_value_text(IntPtr p);

int sqlite3_stmt_isexplain(sqlite3_stmt stmt);
int sqlite3_stmt_busy(sqlite3_stmt stmt);
int sqlite3_stmt_readonly(sqlite3_stmt stmt);

Expand Down
5 changes: 5 additions & 0 deletions src/SQLitePCLRaw.core/raw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,11 @@ static public int sqlite3_bind_parameter_index(sqlite3_stmt stmt, string strName
return sqlite3_bind_parameter_index(stmt, strName.to_utf8z());
}

static public int sqlite3_stmt_isexplain(sqlite3_stmt stmt)
{
return _imp.sqlite3_stmt_isexplain(stmt);
}

static public int sqlite3_stmt_busy(sqlite3_stmt stmt)
{
return _imp.sqlite3_stmt_busy(stmt);
Expand Down
5 changes: 5 additions & 0 deletions src/SQLitePCLRaw.ugly/ugly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ public static void step_done(this sqlite3_stmt stmt)
}
}

public static int stmt_isexplain(this sqlite3_stmt stmt)
{
return raw.sqlite3_stmt_isexplain(stmt);
}

public static int stmt_busy(this sqlite3_stmt stmt)
{
return raw.sqlite3_stmt_busy(stmt);
Expand Down
33 changes: 33 additions & 0 deletions src/common/tests_xunit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,39 @@ public void test_stmt_busy()
}
}

[Fact]
public void test_stmt_isexplain()
{
using (sqlite3 db = ugly.open(":memory:"))
{
db.exec("CREATE TABLE foo (x int);");
db.exec("INSERT INTO foo (x) VALUES (1);");
string sql = "SELECT x FROM foo";
using (sqlite3_stmt stmt = db.prepare(sql))
{
Assert.Equal(sql, stmt.sql());

Assert.Equal(0, stmt.stmt_isexplain());
}

sql = "EXPLAIN SELECT x FROM foo";
using (sqlite3_stmt stmt = db.prepare(sql))
{
Assert.Equal(sql, stmt.sql());

Assert.Equal(1, stmt.stmt_isexplain());
}

sql = "EXPLAIN QUERY PLAN SELECT x FROM foo";
using (sqlite3_stmt stmt = db.prepare(sql))
{
Assert.Equal(sql, stmt.sql());

Assert.Equal(2, stmt.stmt_isexplain());
}
}
}

[Fact]
public void test_stmt_status()
{
Expand Down
9 changes: 9 additions & 0 deletions src/providers/provider.tt
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,11 @@ namespace SQLitePCL
return NativeMethods.sqlite3_step(stm);
}

int ISQLite3Provider.sqlite3_stmt_isexplain(sqlite3_stmt stm)
{
return NativeMethods.sqlite3_stmt_isexplain(stm);
}

int ISQLite3Provider.sqlite3_stmt_busy(sqlite3_stmt stm)
{
return NativeMethods.sqlite3_stmt_busy(stm);
Expand Down Expand Up @@ -1637,6 +1642,7 @@ namespace SQLitePCL
"sqlite3_rollback_hook",
"sqlite3_db_handle",
"sqlite3_next_stmt",
"sqlite3_stmt_isexplain",
"sqlite3_stmt_busy",
"sqlite3_stmt_readonly",
"sqlite3_exec",
Expand Down Expand Up @@ -2106,6 +2112,9 @@ namespace SQLitePCL
<#= attr #>
<#= front #> IntPtr sqlite3_next_stmt(sqlite3 db, IntPtr stmt);

<#= attr #>
<#= front #> int sqlite3_stmt_isexplain(sqlite3_stmt stmt);

<#= attr #>
<#= front #> int sqlite3_stmt_busy(sqlite3_stmt stmt);

Expand Down
2 changes: 0 additions & 2 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ sqlite3_create_window_function

sqlite3_normalized_sql

sqlite3_stmt_isexplain

sqlite3_value_frombind

sqlite3_serialize
Expand Down