diff options
Diffstat (limited to 'vtab.zig')
| -rw-r--r-- | vtab.zig | 29 |
1 files changed, 20 insertions, 9 deletions
| @@ -766,7 +766,8 @@ pub fn VirtualTable( | |||
| 766 | 766 | ||
| 767 | // | 767 | // |
| 768 | 768 | ||
| 769 | const state = @fieldParentPtr(State, "vtab", vtab); | 769 | const nullable_state: ?*State = @fieldParentPtr("vtab", vtab); |
| 770 | const state = nullable_state orelse unreachable; | ||
| 770 | 771 | ||
| 771 | var arena = heap.ArenaAllocator.init(state.module_context.allocator); | 772 | var arena = heap.ArenaAllocator.init(state.module_context.allocator); |
| 772 | defer arena.deinit(); | 773 | defer arena.deinit(); |
| @@ -788,7 +789,9 @@ pub fn VirtualTable( | |||
| 788 | } | 789 | } |
| 789 | 790 | ||
| 790 | fn xDisconnect(vtab: [*c]c.sqlite3_vtab) callconv(.C) c_int { | 791 | fn xDisconnect(vtab: [*c]c.sqlite3_vtab) callconv(.C) c_int { |
| 791 | const state = @fieldParentPtr(State, "vtab", vtab); | 792 | const nullable_state: ?*State = @fieldParentPtr("vtab", vtab); |
| 793 | const state = nullable_state orelse unreachable; | ||
| 794 | |||
| 792 | state.deinit(); | 795 | state.deinit(); |
| 793 | 796 | ||
| 794 | return c.SQLITE_OK; | 797 | return c.SQLITE_OK; |
| @@ -803,7 +806,8 @@ pub fn VirtualTable( | |||
| 803 | } | 806 | } |
| 804 | 807 | ||
| 805 | fn xOpen(vtab: [*c]c.sqlite3_vtab, vtab_cursor: [*c][*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { | 808 | fn xOpen(vtab: [*c]c.sqlite3_vtab, vtab_cursor: [*c][*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { |
| 806 | const state = @fieldParentPtr(State, "vtab", vtab); | 809 | const nullable_state: ?*State = @fieldParentPtr("vtab", vtab); |
| 810 | const state = nullable_state orelse unreachable; | ||
| 807 | 811 | ||
| 808 | const cursor_state = CursorState.init(state.module_context, state.table) catch |err| { | 812 | const cursor_state = CursorState.init(state.module_context, state.table) catch |err| { |
| 809 | logger.err("unable to create cursor state, err: {!}", .{err}); | 813 | logger.err("unable to create cursor state, err: {!}", .{err}); |
| @@ -815,14 +819,17 @@ pub fn VirtualTable( | |||
| 815 | } | 819 | } |
| 816 | 820 | ||
| 817 | fn xClose(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { | 821 | fn xClose(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { |
| 818 | const cursor_state = @fieldParentPtr(CursorState, "vtab_cursor", vtab_cursor); | 822 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 823 | const cursor_state = nullable_cursor_state orelse unreachable; | ||
| 824 | |||
| 819 | cursor_state.deinit(); | 825 | cursor_state.deinit(); |
| 820 | 826 | ||
| 821 | return c.SQLITE_OK; | 827 | return c.SQLITE_OK; |
| 822 | } | 828 | } |
| 823 | 829 | ||
| 824 | fn xEof(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { | 830 | fn xEof(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { |
| 825 | const cursor_state = @fieldParentPtr(CursorState, "vtab_cursor", vtab_cursor); | 831 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 832 | const cursor_state = nullable_cursor_state orelse unreachable; | ||
| 826 | const cursor = cursor_state.cursor; | 833 | const cursor = cursor_state.cursor; |
| 827 | 834 | ||
| 828 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); | 835 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); |
| @@ -859,7 +866,8 @@ pub fn VirtualTable( | |||
| 859 | } | 866 | } |
| 860 | 867 | ||
| 861 | fn xFilter(vtab_cursor: [*c]c.sqlite3_vtab_cursor, idx_num: c_int, idx_str: [*c]const u8, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) c_int { | 868 | fn xFilter(vtab_cursor: [*c]c.sqlite3_vtab_cursor, idx_num: c_int, idx_str: [*c]const u8, argc: c_int, argv: [*c]?*c.sqlite3_value) callconv(.C) c_int { |
| 862 | const cursor_state = @fieldParentPtr(CursorState, "vtab_cursor", vtab_cursor); | 869 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 870 | const cursor_state = nullable_cursor_state orelse unreachable; | ||
| 863 | const cursor = cursor_state.cursor; | 871 | const cursor = cursor_state.cursor; |
| 864 | 872 | ||
| 865 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); | 873 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); |
| @@ -884,7 +892,8 @@ pub fn VirtualTable( | |||
| 884 | } | 892 | } |
| 885 | 893 | ||
| 886 | fn xNext(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { | 894 | fn xNext(vtab_cursor: [*c]c.sqlite3_vtab_cursor) callconv(.C) c_int { |
| 887 | const cursor_state = @fieldParentPtr(CursorState, "vtab_cursor", vtab_cursor); | 895 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 896 | const cursor_state = nullable_cursor_state orelse unreachable; | ||
| 888 | const cursor = cursor_state.cursor; | 897 | const cursor = cursor_state.cursor; |
| 889 | 898 | ||
| 890 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); | 899 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); |
| @@ -902,7 +911,8 @@ pub fn VirtualTable( | |||
| 902 | } | 911 | } |
| 903 | 912 | ||
| 904 | fn xColumn(vtab_cursor: [*c]c.sqlite3_vtab_cursor, ctx: ?*c.sqlite3_context, n: c_int) callconv(.C) c_int { | 913 | fn xColumn(vtab_cursor: [*c]c.sqlite3_vtab_cursor, ctx: ?*c.sqlite3_context, n: c_int) callconv(.C) c_int { |
| 905 | const cursor_state = @fieldParentPtr(CursorState, "vtab_cursor", vtab_cursor); | 914 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 915 | const cursor_state = nullable_cursor_state orelse unreachable; | ||
| 906 | const cursor = cursor_state.cursor; | 916 | const cursor = cursor_state.cursor; |
| 907 | 917 | ||
| 908 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); | 918 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); |
| @@ -945,7 +955,8 @@ pub fn VirtualTable( | |||
| 945 | } | 955 | } |
| 946 | 956 | ||
| 947 | fn xRowid(vtab_cursor: [*c]c.sqlite3_vtab_cursor, row_id_ptr: [*c]c.sqlite3_int64) callconv(.C) c_int { | 957 | fn xRowid(vtab_cursor: [*c]c.sqlite3_vtab_cursor, row_id_ptr: [*c]c.sqlite3_int64) callconv(.C) c_int { |
| 948 | const cursor_state = @fieldParentPtr(CursorState, "vtab_cursor", vtab_cursor); | 958 | const nullable_cursor_state: ?*CursorState = @fieldParentPtr("vtab_cursor", vtab_cursor); |
| 959 | const cursor_state = nullable_cursor_state orelse unreachable; | ||
| 949 | const cursor = cursor_state.cursor; | 960 | const cursor = cursor_state.cursor; |
| 950 | 961 | ||
| 951 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); | 962 | var arena = heap.ArenaAllocator.init(cursor_state.module_context.allocator); |