Re:Extending SQLite with Rust
by michaelsbradley on Monday September 05, 2022 @11:34PM
(#32732504)
For what it's worth, SQLite works just fine for some blockchains without Rust extensions, e.g. nimbus-eth2[+] uses SQLite with `journal_mode = WAL` to locally persist Beacon Chain data.
Other Beacon Chain client implementations (there are several in wide use) may use SQLite, or something else, I'm not sure at the moment.
Re:Extending SQLite with Rust
by bob1029 on Monday September 05, 2022 @02:42PM
(#32727699)
This is great to see. We've been using UDFs with SQLite and .NET for about 3 years now.
With just a little bit of imagination, you can build a very powerful domain-specific language on top of a SQL dialect. There is nothing that says your new SQL functions have to be free from side effects either.
You can also do some crazy stuff with recursive SQL evaluation. I.e. a UDF that executes raw SQL command text, which itself can contain the same invocation. Bonus points if this command text resides in the same database and can reflect/edit itself at runtime...
Re:Extending SQLite with Rust
by polyrand on Monday September 05, 2022 @02:56PM
(#32727854)
Yes! I love UDFs in SQLite:
1. I can just write functions in whatever programming language I want.
2. Not having to worry as much about overwriting other UDFs, since different connections can have the same UDF with a different implementation.
3. Having the DB (SQLite) and the function definitions in the same application code and in the same process makes some things a lot easier and flexible.
Re:Extending SQLite with Rust
by bear24rw on Tuesday September 06, 2022 @12:21AM
(#32732799)
> You can also do some crazy stuff with recursive SQL evaluation. I.e. a UDF that executes raw SQL command text, which itself can contain the same invocation. Bonus points if this command text resides in the same database and can reflect/edit itself at runtime...
This is super intriguing, would love to see more details / examples of this.
https://news.ycombinator.com/item?id=32725455
“How Rust Extensions to SQLite Saved The Blockchain” would be a banger in 2022! Someone do it!
Other Beacon Chain client implementations (there are several in wide use) may use SQLite, or something else, I'm not sure at the moment.
[+] https://github.com/status-im/nimbus-eth2#readme
With just a little bit of imagination, you can build a very powerful domain-specific language on top of a SQL dialect. There is nothing that says your new SQL functions have to be free from side effects either.
You can also do some crazy stuff with recursive SQL evaluation. I.e. a UDF that executes raw SQL command text, which itself can contain the same invocation. Bonus points if this command text resides in the same database and can reflect/edit itself at runtime...
1. I can just write functions in whatever programming language I want.
2. Not having to worry as much about overwriting other UDFs, since different connections can have the same UDF with a different implementation.
3. Having the DB (SQLite) and the function definitions in the same application code and in the same process makes some things a lot easier and flexible.
I actually wrote about that too:
https://ricardoanderegg.com/posts/sqlite-developer-experienc...
This is super intriguing, would love to see more details / examples of this.