using clang as a library is pretty cool hey đź‘€
fucken sickos yes 

Oh yes. I have built postgres server as a static library with no .data* or .bss sections, just .tdata and .tbss :)

* there are some .data.rel.ro symbols but they are for read only data anyway so they don't count

It errors on bootstrap... but it gets pretty far through (initializes transaction contexts and everything!) and shuts down using Postgres' actual error handling machinery!
Next I think I'm going to gut the error handling stuff and route it through rust logs and panics instead :)

postgres logs/panics are now rust logs/panics :)

even RUST_BACKTRACE=1 Just Works :) :)

@hailey im operating in a very sleep deprived state so forgive me but what is the goal of “pg as a library”? sqlite but make it postgres? don’t have to install the package & run the daemon independently?
@hailey (other than being cool. that’s a great goal and you are succeeding)
@phillmv yeah :)
@phillmv the original driver of this project is making mastodon easier to deploy. but I think if I can pull this off, it's also just good and useful tech in its own right
@hailey @phillmv this is extreme galaxy brain shit, and I kind of love it.

@hailey @phillmv oh absolutely useful - some of the approaches I've been going with self hosted/Enterprise software could benefit from this.

It feels a bit much in some deployment cases to be running the whole big thing when I'm trying to get a bunch of services to feel like a single thing.

@hailey what are you doing next?

I recently tried to use Postgres as a library and unfortunately quickly discovered that there’s a lot of global state and global functions :/

@judofyr I'm gonna try to make it a library :)

@hailey aaah. I was trying to tweak the internals so that tables were not stored on disk, but I could use parts of the query engine. it was *complicated*.

but if you're just using the stock Postgres features then I guess librarizing it will be okay!

@judofyr I started hooking up a SQLite storage backend >_>
@hailey hopefully you're using a more public API than I was trying. I was trying to make it not use _anything_ on disk. I started poking into the "relation cache" and then I got kinda stuck.

@judofyr I've got a branch off postgres 15.1 I've been working away on here: https://github.com/haileys/postgres/commits/minigres-15.1

Most of the large diffs there are automated, and otherwise I've tried to keep my changes localised to ease forward porting. There's also a bunch of code on the rust side that I'm working on in a private repo. Will see how it works out I guess!

Commits · haileys/postgres

Mirror of the official PostgreSQL GIT repository. Note that this is just a *mirror* - we don't work with pull requests on github. To contribute, please see https://wiki.postgresql.org/wiki/Subm...

GitHub

@hailey aaah. my purpose was to not change Postgres itself at all and only use the public functions.

oh wow, rewriting the code automatically to make global variables into function calls is super neat!

@judofyr here's a little snippet :)
@hailey embedding software that was never meant to be embedded is my favorite niche like https://github.com/bouk/kubectl-dashboard
GitHub - bouk/kubectl-dashboard: Instantly get a Kubernetes dashboard

Instantly get a Kubernetes dashboard. Contribute to bouk/kubectl-dashboard development by creating an account on GitHub.

GitHub