rustdb 0.1.29

SQL database (in development)
Documentation
# Interface The method [Database]::run (or alternatively Database::run_timed) is called to execute an SQL query. This takes a [Transaction] parameter which accumulates SELECT results and which also has methods for accessing the environment and controlling output. Custom builtin functions implement [CExp] and have access to the query via an [EvalEnv] parameter, which can be downcast if necessary. # Examples ``` use rustdb::{Database, SharedPagedData, SimpleFileStorage, WebTransaction, INITSQL}; use std::net::TcpListener; use std::sync::Arc; let sfs = Box::new(SimpleFileStorage::new( "c:\\Users\\pc\\rust\\sftest01.rustdb", )); let spd = Arc::new(SharedPagedData::new(sfs)); let apd = spd.open_write(); let db = Database::new(apd, INITSQL); let listener = TcpListener::bind("127.0.0.1:3000").unwrap(); for tcps in listener.incoming() { if let Ok(mut tcps) = tcps { if let Ok(mut wq) = WebTransaction::new(&tcps) { // wq.trace(); let sql = "EXEC web.Main()"; // Execute SQL. http response, SQL output, (status,headers,content) is accumulated in wq. db.run_timed(&sql, &mut wq); // Write the http response to the TCP stream. let _err = wq.write(&mut tcps); // Save database changes to disk. db.save(); } } } ``` [See here](https://github.com/georgebarwood/RustDB/blob/main/examples/axumtest.rs) for more advanced example ( Axum webserver with ARGON hash function and query logging ). # Features This crate supports two cargo features. - `builtin` : Allows extra SQL builtin functions to be defined. - `max` : Exposes maximal interface, including all internal modules (default). # General Design of Database SortedFile stores fixed size Records in a tree of Pages. SortedFile is used to implement: - Variable length values ( which are split into fragments - see bytes module - although up to 15 bytes can be stored directly. ). - Database Table storage. Each record has a 64-bit Id. - Index storage ( an index record refers back to the main table ). When a page becomes too big, it is split into two pages. Each page is implemented as a binary tree ( so there is a tree of trees ). [SharedPagedData] allows logical database pages to be shared to allow concurrent readers. # ToDo List Implement DROP INDEX, ALTER TABLE, fully implement CREATE INDEX. Consider replication/backup/durability issues [Here](https://en.wikipedia.org/wiki/Durability_(database_systems)) Implement email in example program. Replication of log files. Server status. Sort out error handling for PARSEINT etc. Work on improving/testing SQL code, browse schema, float I/O. Login.