Example sqlite3 Dynamic Loadable Extension in Rust - vfs and vtab modules - port of vfsstat.c

Overview

Example sqlite3 Dynamic Loadable Extension in Rust - vfs and vtab modules

The vfs and vtab

This is a port of the official ext/misc/vfsstat.c sqlite3 extension. It implements a VFS and a virtual table that keeps IO statistics.

Query the virtual table by issuing SELECT * FROM vtabstat.

Build

cargo build --release

Output will be located at target/release/libvfsstat_rs.so

Use

Assuming libvfsstat_rs.so is in current directory,

$ sqlite3
sqlite> .load ./libvfsstat_rs
sqlite> .open ../../test.db
sqlite> .schema
CREATE TABLE person (
                  id              INTEGER PRIMARY KEY,
                  name            TEXT NOT NULL UNIQUE,
                  data            BLOB
                  );
sqlite> select * from person;
id  name                              data
--  --------------------------------  -------------
1   Steven                            NULL
2   05504B041661AAD1320A8537EB8234D2  zÔ];[^;H
3   4967EEDBF69420D82C6B1BCFB31397DD  ?BiΘI
4   19D0F5974A48AA561B7097CDA39E4047
                                      l!Xk- 5
5   1F1FFD477777F5AA5CBFF916A4AF9593  + 텸vy\Y
6   0925676226D46FB4EC6DAEB11D130350  <</jޏ
7   5D6F4F219D2E3FAF7D61CA5237F106F8  (nlZ
8   FFD140BD25C1CA899446F2C9C2631A51  ,9^<      p
9   F9F66F44D64FC54FDFAEBD3750FD3513  [C@E
sqlite> select * from vtabstat;
file            stat         count
--------------  -----------  -----
main            bytesIn      12388
main            bytesOut     0
main            read         4
main            write        0
main            sync         0
main            open         1
main            lock         1
main            access       0
main            delete       0
main            fullPath     0
main            random       0
main            sleep        0
main            currentTime  0
journal         bytesIn      0
journal         bytesOut     0
journal         read         0
journal         write        0
journal         sync         0
journal         open         0
journal         lock         0
journal         access       0
journal         delete       0
journal         fullPath     0
journal         random       0
journal         sleep        0
journal         currentTime  0
wal             bytesIn      0
wal             bytesOut     0
wal             read         0
wal             write        0
wal             sync         0
wal             open         1
wal             lock         0
wal             access       0
wal             delete       0
wal             fullPath     0
wal             random       0
wal             sleep        0
wal             currentTime  0
master-journal  bytesIn      0
master-journal  bytesOut     0
master-journal  read         0
master-journal  write        0
master-journal  sync         0
master-journal  open         0
master-journal  lock         0
master-journal  access       0
master-journal  delete       0
master-journal  fullPath     0
master-journal  random       0
master-journal  sleep        0
master-journal  currentTime  0
sub-journal     bytesIn      0
sub-journal     bytesOut     0
sub-journal     read         0
sub-journal     write        0
sub-journal     sync         0
sub-journal     open         0
sub-journal     lock         0
sub-journal     access       0
sub-journal     delete       0
sub-journal     fullPath     0
sub-journal     random       0
sub-journal     sleep        0
sub-journal     currentTime  0
temp-database   bytesIn      0
temp-database   bytesOut     0
temp-database   read         0
temp-database   write        0
temp-database   sync         0
temp-database   open         0
temp-database   lock         0
temp-database   access       0
temp-database   delete       0
temp-database   fullPath     0
temp-database   random       0
temp-database   sleep        0
temp-database   currentTime  0
temp-journal    bytesIn      0
temp-journal    bytesOut     0
temp-journal    read         0
temp-journal    write        0
temp-journal    sync         0
temp-journal    open         0
temp-journal    lock         0
temp-journal    access       0
temp-journal    delete       0
temp-journal    fullPath     0
temp-journal    random       0
temp-journal    sleep        0
temp-journal    currentTime  0
transient-db    bytesIn      0
transient-db    bytesOut     0
transient-db    read         0
transient-db    write        0
transient-db    sync         0
transient-db    open         0
transient-db    lock         0
transient-db    access       0
transient-db    delete       0
transient-db    fullPath     0
transient-db    random       0
transient-db    sleep        0
transient-db    currentTime  0
*               bytesIn      0
*               bytesOut     0
*               read         0
*               write        0
*               sync         0
*               open         0
*               lock         0
*               access       2
*               delete       0
*               fullPath     1
*               random       0
*               sleep        0
You might also like...
SQLite Extension adding various hashing functions like MD5, SHA1, SHA256, SHA512, etc.

sqlite-hashes Use this crate to add various hash functions to SQLite, including MD5, SHA1, SHA256, and SHA512. This crate uses rusqlite to add user-de

Rust and TypeScript example code for finding all members from a collection id.

get-collection-rs Use the Crawler cargo build --release ./target/release/get-collection rpc_node collection_id Example: ./target/release/get-col

CRUD example with Rocket, Toql and MySQL

Todo (Rocket, Toql, MySQL) This is a little REST server built with Rocket, Toql and MySQL. The server allows to call CRUD functions on a Todo item. It

A Rust port of BuntDB

This is a Rust port of fantasitc BuntDB project by Josh Baker. Big parts of this project are taken directly from BuntDB including API surface and API

A Rust port of Pimoroni's uc8151 driver

uc8151-rs - a no-std Rust library for the UC8151(IL0373) e-ink display This is a Rust port of the Pimoroni UC8151 library. UC8151 is also sometimes re

A port of `java.util.*SummaryStatistics` as a Redis Module

RedisNumbersStats RedisNumbersStats is a Redis module that implements a Redis version of the Java Util *SummaryStatistics classes, such as DoubleSumma

A place for the community to upload example Scrypto code

community-scrypto A place for the community to upload example Scrypto code. Please fork from main, work out of a sub-directory of your choosing, and t

A collection of example project using Njord.
A collection of example project using Njord.

Example Projects A collection of example project using Njord. Contributors The following contributors have either helped to start this project, have c

ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-text search.
ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-text search.

ReefDB ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-

Owner
Manos Pitsidianakis
Electrical and Computer Engineering
Manos Pitsidianakis
Build SQLite virtual file systems (VFS) by implementing a simple Rust trait.

sqlite-vfs Build SQLite virtual file systems (VFS) by implementing a simple Rust trait. Documentation | Example This library is build for my own use-c

Markus Ast 56 Dec 19, 2022
sqlite3 Rewritten in RiiR Rust 🦀🦀🦀

sqlite3 Rewritten in RiiR Rust ?? ?? ?? Finally, one of the best written software paired with one of the best writable programming language‽ Fearless

Manos Pitsidianakis 142 Jan 3, 2023
SQLite3 Bindings for Rust

SQLite3 Bindings for Rust To compile use rustc src/sqlite3.rs or if you have Cargo installed cargo build. The interface is currently evolving both alo

null 74 Aug 6, 2022
Rustic bindings for sqlite3

Rust-Sqlite3 Rustic bindings for sqlite3. OBSOLETE in favor of jgallagher/rusqlite Copyright (c) 2014-2017 Dan Connolly and contributors Share and enj

Dan Connolly 57 Sep 26, 2022
🐚 An async & dynamic ORM for Rust

SeaORM ?? An async & dynamic ORM for Rust SeaORM SeaORM is a relational ORM to help you build web services in Rust with the familiarity of dynamic lan

SeaQL 3.5k Jan 6, 2023
A SQLite extension for quickly generating random numbers, booleans, characters, and blobs

sqlite-fastrandom A SQLite extension for quickly generating random numbers, booleans, characters, and blobs. Not cryptographically secure. Based on sq

Alex Garcia 11 Feb 2, 2023
fast & easy CLI and vscode extension specialized to format MySQL INSERT queries.

insertfmt fast & easy CLI specialized to format MySQL INSERT queries. format queries so that they look like a table. NOTE: If you wanna use the VSCode

canalun 7 May 2, 2023
postgres-ical - a PostgreSQL extension that adds features related to parsing RFC-5545 « iCalendar » data from within a PostgreSQL database

postgres-ical - a PostgreSQL extension that adds features related to parsing RFC-5545 « iCalendar » data from within a PostgreSQL database

Edgar Onghena 1 Feb 23, 2022
Mycelite is a SQLite extension that allows you to synchronize changes from one instance of SQLite to another.

Mycelite What is Mycelite? Mycelite is a SQLite extension that allows you to synchronize changes from one instance of SQLite to another. Currently, it

Mycelial 16 Jan 2, 2023
SQLite extension for working with operating system's clipboard (copy/paste functions)

SQLite extension for working with operating system's clipboard This extension adds the following functions to SQLite: Copy Paste Long name CLIPBOARD_C

Sergey Khabibullin 4 Jun 12, 2023