Skip to content

euphoricair7/glyph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

glyph

SQLite-inspired pager-backed database written in C, built from first principles.

Features

  • Insert rows containing an integer id, username, and email
  • Select all stored rows with a simple table scan
  • Validate input (positive IDs, bounded string lengths)
  • Persist data to disk via a lightweight pager abstraction
  • Support meta commands such as .exit

Build

Compile the main implementation with standard warnings enabled:

gcc -Wall -Wextra -std=c11 -o maincode src/maincode.c

For the experimental variant:

gcc -Wall -Wextra -std=c11 -o maincode_experimental src/maincode_experimental.c

Run

Start the database REPL:

./maincode

Or point it at a specific database file:

./maincode mydb.db

Example Session

$ ./maincode mydb.db
db > insert 1 john john@example.com
Executed.
db > insert 2 jane jane@example.com
Executed.
db > select
(1, john, john@example.com)
(2, jane, jane@example.com)
Executed.
db > .exit

Testing

Python test cases live under tests/testcases/, and test runners live under tests/testscripts/.

  • Run the main Python suite:

     python3 tests/testcases/test_database.py -v
  • Execute the shell-based regression tests:

     tests/testscripts/run_tests.sh

Project Layout

glyph/
├── src/
│   ├── maincode.c
│   ├── maincode.h
│   ├── maincode_experimental.c
│   └── maincode_experimental.h
├── tests/
│   ├── testcases/
│   │   ├── queries.txt
│   │   ├── test_database.py
│   │   └── test_database_fixed.py
│   └── testscripts/
│       ├── debug_btree.sh
│       ├── debug_persistence.sh
│       ├── insert_data.sh
│       ├── run_tests.sh
│       ├── setup_experimental.sh
│       ├── test_btree_basic.sh
│       ├── test_dbs.sh
│       ├── test_experimental.sh
│       ├── test_multi_table.sh
│       └── test_show_tables.sh
├── tools/
│   └── insert_data.py
└── docs/
		├── LICENSE
		└── README.md

Development Tips

  • Clean build:

     rm -f maincode maincode_experimental *.db
     gcc -Wall -Wextra -std=c11 -o maincode src/maincode.c
  • Run under gdb:

     gcc -g -Wall -Wextra -std=c11 -o maincode src/maincode.c
     gdb ./maincode
  • Check for leaks:

     valgrind --leak-check=full ./maincode test.db

License

See docs/LICENSE.

About

A cutesy pager-backed SQL engine built from first principles

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published