Crate rustdb[][src]

Expand description

ToDo List:

Test cookies.

Make sys.Function a system table. Index sys.Schema.

Implement DROP INDEX, ALTER TABLE, fully implement CREATE INDEX.

Sort out error handling for PARSEINT etc.

Work on improving/testing SQL code, browse schema, float I/O.

Bug in date - Jun 5, 1825 doesn’t work properly.

Database with SQL-like language. Example program:

use rustdb::{pstore::SharedPagedData, stg::SimpleFileStorage, web::WebQuery, Database, init::INITSQL};
use std::net::TcpListener;
use std::sync::Arc;

fn main() {
   let sfs = Box::new(SimpleFileStorage::new(
       "c:\\Users\\pc\\rust\\sftest01.rustdb",
   ));
   let spd = Arc::new(SharedPagedData::new(sfs));
   let wstg = spd.open_write();
   let db = Database::new(wstg, INITSQL);
   let listener = TcpListener::bind("127.0.0.1:7878").unwrap();
   for tcps in listener.incoming() {
       let mut tcps = tcps.unwrap();
       let mut wq = WebQuery::new(&tcps); // Reads the http request from the TCP stream into wq.
       let sql = "EXEC web.Main()";
       db.run_timed(&sql, &mut wq); // Executes SQL, http response, SQL output, (status,headers,content) is accumulated in wq.
       wq.write(&mut tcps); // Write the http response to the TCP stream.
       db.save(); // Saves database changes to disk.
   }
}

General Design of Database

SortedFile stores fixed size Records in a tree of Pages. SortedFile is used to implement:

(1) Variable length values ( which are split into fragments - see bytes module - although up to 15 bytes can be stored directly. ).

(2) Database Table storage. Each record has a 64-bit Id.

(3) Index storage ( an index record refers back to the main table ).

Pages have a maximum size, and are stored in CompactFile, which stores logical pages in smaller regions of backing storage.

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 ).

Modules

Compilation of builtin functions.

Storage of variable length values : ByteStorage.

Cache to retain page values at different times.

Structs that implement CExp trait.

CompactFile : storage of logical pages in smaller regions of backing storage.

Functions to compile parsed expressions, checking types.

Instruction execution.

Expression types, result of parsing.

Under development.

Initial SQL

Page for SortedFile.

Parser.

Paged data storage.

Instruction and other run time types.

Sorted Record storage.

Backing storage for CompactFile.

System table functions.

Table, ColInfo, Row and other Table types.

Utility functions and macros.

Run-time Value.

WebQuery struct for making a http web server.

Structs

Database with SQL-like interface.

Traits

Input/Output message. Query and response.

Type Definitions

Rc<Database>

Arc<Vec<u8>>