summaryrefslogtreecommitdiff
path: root/sqlite.zig
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sqlite.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/sqlite.zig b/sqlite.zig
index 09e13ba..1fe8aea 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -20,8 +20,13 @@ const getLastDetailedErrorFromDb = errors.getLastDetailedErrorFromDb;
20const getDetailedErrorFromResultCode = errors.getDetailedErrorFromResultCode; 20const getDetailedErrorFromResultCode = errors.getDetailedErrorFromResultCode;
21 21
22const getTestDb = @import("test.zig").getTestDb; 22const getTestDb = @import("test.zig").getTestDb;
23pub const vtab = @import("vtab.zig");
23const helpers = @import("helpers.zig"); 24const helpers = @import("helpers.zig");
24 25
26test {
27 _ = @import("vtab.zig");
28}
29
25const logger = std.log.scoped(.sqlite); 30const logger = std.log.scoped(.sqlite);
26 31
27/// Text is used to represent a SQLite TEXT value when binding a parameter or reading a column. 32/// Text is used to represent a SQLite TEXT value when binding a parameter or reading a column.
@@ -787,6 +792,26 @@ pub const Db = struct {
787 try stmt.exec(new_options, .{}); 792 try stmt.exec(new_options, .{});
788 } 793 }
789 } 794 }
795
796 pub fn createVirtualTable(
797 self: *Self,
798 comptime name: [:0]const u8,
799 module_context: *vtab.ModuleContext,
800 comptime Table: type,
801 ) !void {
802 const VirtualTableType = vtab.VirtualTable(name, Table);
803
804 const result = c.sqlite3_create_module_v2(
805 self.db,
806 name,
807 &VirtualTableType.module,
808 module_context,
809 null,
810 );
811 if (result != c.SQLITE_OK) {
812 return errors.errorFromResultCode(result);
813 }
814 }
790}; 815};
791 816
792/// FunctionContext is the context passed as first parameter in the `step` and `finalize` functions used with `createAggregateFunction`. 817/// FunctionContext is the context passed as first parameter in the `step` and `finalize` functions used with `createAggregateFunction`.