From: Evan Nemerson Date: Mon, 19 Apr 2010 09:17:23 +0000 (-0700) Subject: sqlite3: add many missing bindings X-Git-Tag: 0.9.1~138 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=90e32db5350223d59e68ae252a5580c40b926477;p=thirdparty%2Fvala.git sqlite3: add many missing bindings --- diff --git a/vapi/sqlite3.vapi b/vapi/sqlite3.vapi index 43d71e090..3b680e670 100644 --- a/vapi/sqlite3.vapi +++ b/vapi/sqlite3.vapi @@ -29,8 +29,8 @@ namespace Sqlite { public int busy_timeout (int ms); public int changes (); [CCode (cname = "sqlite3_exec")] - private int _exec (string sql, Callback? sqlite3_callback = null, out unowned string errmsg = null); - [CCode (cname = "_vala_sqlite3_exec")] + public int _exec (string sql, Callback? sqlite3_callback = null, out unowned string errmsg = null); + [CCode (cname = "_sqlite3_exec")] public int exec (string sql, Callback? sqlite3_callback = null, out string errmsg = null) { unowned string sqlite_errmsg; var ec = this._exec (sql, sqlite3_callback, out sqlite_errmsg); @@ -44,12 +44,13 @@ namespace Sqlite { public int get_autocommit (); public void interrupt (); public int64 last_insert_rowid (); + public int limit (Sqlite.Limit id, int new_val); public int total_changes (); public int complete (string sql); [CCode (cname = "sqlite3_get_table")] - private int _get_table (string sql, [CCode (array_length = false)] out unowned string[] resultp, out int nrow, out int ncolumn, out unowned string? errmsg = null); + public int _get_table (string sql, [CCode (array_length = false)] out unowned string[] resultp, out int nrow, out int ncolumn, out unowned string? errmsg = null); private static void free_table ([CCode (array_length = false)] string[] result); - [CCode (cname = "_vala_sqlite3_get_table")] + [CCode (cname = "_sqlite3_get_table")] public int get_table (string sql, out string[] resultp, out int nrow, out int ncolumn, out string? errmsg = null) { unowned string sqlite_errmsg; unowned string[] sqlite_resultp; @@ -72,17 +73,23 @@ namespace Sqlite { public static int open_v2 (string filename, out Database db, int flags = OPEN_READWRITE | OPEN_CREATE, string? zVfs = null); public int errcode (); public unowned string errmsg (); + public unowned Sqlite.Statement next_stmt (Sqlite.Statement? current); public int prepare (string sql, int n_bytes, out Statement stmt, out unowned string tail = null); public int prepare_v2 (string sql, int n_bytes, out Statement stmt, out unowned string tail = null); + public int set_authorizer (AuthorizeCallback? auth); + [CCode (cname = "sqlite3_db_status")] + public int status (Sqlite.DatabaseStatus op, out int pCurrent, out int pHighwater, int resetFlag = 0); + public int table_column_metadata (string db_name, string table_name, string column_name, out string? data_type, out string? collation_sequence, out int? not_null, out int? primary_key, out int? auto_increment); public void trace (TraceCallback? xtrace); public void profile (ProfileCallback? xprofile); public void progress_handler (int n_opcodes, Sqlite.ProgressCallback? progress_handler); public void commit_hook (CommitCallback? commit_hook); public void rollback_hook (RollbackCallback? rollback_hook); - [CCode (simple_generics = true)] public int create_function (string zFunctionName, int nArg, int eTextRep, void * user_data, UserFuncCallback? xFunc, UserFuncCallback? xStep, UserFuncFinishCallback? xFinal); } + [CCode (instance_pos = 0)] + public delegate int AuthorizeCallback (Sqlite.Action action, string? p1, string? p2, string db_name, string? responsible); [CCode (instance_pos = 0)] public delegate void TraceCallback (string message); [CCode (instance_pos = 0)] @@ -95,6 +102,26 @@ namespace Sqlite { [CCode (has_target = false)] public delegate void UserFuncFinishCallback (Sqlite.Context context); + public unowned string? compileoption_get (int n); + public int compileoption_used (string option_name); + public static int complete (string sql); + [CCode (sentinel = "")] + public static int config (Sqlite.Config op, ...); + public unowned string libversion (); + public int libversion_number (); + [PrintfFormat] + public void log (int error_code, string format, ...); + public unowned string sourceid (); + public static int status (Sqlite.Status op, out int pCurrent, out int pHighwater, int resetFlag = 0); + public static int threadsafe (); + + [CCode (cname = "SQLITE_VERSION")] + public const string VERSION; + [CCode (cname = "SQLITE_VERSION_NUMBER")] + public const int VERSION_NUMBER; + [CCode (cname = "SQLITE_SOURCE_ID")] + public const string SOURCE_ID; + /* Dynamically Typed Value Object */ [Compact] [CCode (cname = "sqlite3_value")] @@ -211,6 +238,88 @@ namespace Sqlite { [CCode (cname = "SQLITE_UTF16_ALIGNED")] public const int UTF16_ALIGNED; + [CCode (cname = "int", cprefix = "SQLITE_")] + public enum Action { + CREATE_INDEX, + CREATE_TABLE, + CREATE_TEMP_INDEX, + CREATE_TEMP_TABLE, + CREATE_TEMP_TRIGGER, + CREATE_TEMP_VIEW, + CREATE_TRIGGER, + CREATE_VIEW, + DELETE, + DROP_INDEX, + DROP_TABLE, + DROP_TEMP_INDEX, + DROP_TEMP_TABLE, + DROP_TEMP_TRIGGER, + DROP_TEMP_VIEW, + DROP_TRIGGER, + DROP_VIEW, + INSERT, + PRAGMA, + READ, + SELECT, + TRANSACTION, + UPDATE, + ATTACH, + DETACH, + ALTER_TABLE, + REINDEX, + ANALYZE, + CREATE_VTABLE, + DROP_VTABLE, + FUNCTION, + SAVEPOINT, + COPY + } + + [CCode (cname = "int", cprefix = "SQLITE_CONFIG_")] + public enum Config { + SINGLETHREAD, + MULTITHREAD, + SERIALIZED, + MALLOC, + GETMALLOC, + SCRATCH, + PAGECACHE, + HEAP, + MEMSTATUS, + MUTEX, + GETMUTEX, + LOOKASIDE, + PCACHE, + GETPCACHE, + LOG, + } + + [CCode (cname = "int", cprefix = "SQLITE_DBSTATUS_")] + public enum DatabaseStatus { + LOOKASIDE_USED + } + + [CCode (cname = "int", cprefix = "SQLITE_LIMIT_")] + public enum Limit { + LENGTH, + SQL_LENGTH, + COLUMN, + EXPR_DEPTH, + COMPOUND_SELECT, + VDBE_OP, + FUNCTION_ARG, + ATTACHED, + LIKE_PATTERN_LENGTH, + VARIABLE_NUMBER, + TRIGGER_DEPTH + } + + [CCode (cname = "int", cprefix = "SQLITE_STMTSTATUS_")] + public enum StatementStatus { + FULLSCAN_STEP, + SORT + } + [CCode (cname = "int", cprefix = "SQLITE_STATUS_")] public enum Status { MEMORY_USED, @@ -221,12 +330,7 @@ namespace Sqlite { MALLOC_SIZE, PARSER_STACK, PAGECACHE_SIZE, - SCRATCH_SIZE, - - [CCode (cname = "SQLITE_STMTSTATUS_FULLSCAN_STEP")] - STMT_FULLSCAN_STEP, - [CCode (cname = "SQLITE_STMTSTATUS_SORT")] - STMT_SORT + SCRATCH_SIZE } /* SQL Statement Object */ @@ -242,7 +346,7 @@ namespace Sqlite { public unowned Database db_handle (); public int reset (); [CCode (cname = "sqlite3_stmt_status")] - public int status (Sqlite.Status op, int resetFlg); + public int status (Sqlite.StatementStatus op, int resetFlg = 0); public int step (); public int bind_blob (int index, void* value, int n, GLib.DestroyNotify destroy_notify); public int bind_double (int index, double value); @@ -271,6 +375,14 @@ namespace Sqlite { public static void* realloc (void* mem, int n_bytes); [CCode (cname = "sqlite3_free")] public static void free (void* mem); + [CCode (cname = "sqlite3_release_memory")] + public static int release (int bytes); + [CCode (cname = "sqlite3_memory_used")] + public static int64 used (); + [CCode (cname = "sqlite3_memory_highwater")] + public static int64 highwater (int reset = 0); + [CCode (cname = "sqlite3_soft_heap_limit")] + public static void soft_heap_limit (int limit); } [Compact] @@ -279,6 +391,8 @@ namespace Sqlite { [CCode (cname = "sqlite3_mutex_alloc")] public Mutex (int mutex_type = MUTEX_RECURSIVE); public void enter (); + public int held (); + public int notheld (); public int @try (); public void leave (); } @@ -309,5 +423,14 @@ namespace Sqlite { [CCode (cname = "sqlite3_aggregate_context")] public void * aggregate (int n_bytes); } + + [Compact, CCode (cname = "sqlite3_backup", free_function = "sqlite3_backup_finish", cprefix = "sqlite3_backup_")] + public class Backup { + [CCode (cname = "sqlite3_backup_init")] + public Backup (Database dest, string dest_name, Database source, string source_name); + public int step (int nPage); + public int remaining (); + public int pagecount (); + } }