Live data from Hacker News

SQLite should have (Rust-style) editions

mort.coffee

71–80 of 186 posts

Re: SQLite should have (Rust-style) editions

#71
post #43
post #2

Oh hi, author here. Fun to see this make it to HN.

Found what appears to be a minor mistake you may want to fix: "This means that a dangling reference easily results in a reference to the wrong column " should probably be "... a reference to the wrong row ". (In the paragraph about SQLite's tendency to re-use ROWIDs).

You're right, thanks. Fixed

Re: SQLite should have (Rust-style) editions

#72
post #65
post #63

Why not a .conf file like everything in /etc or postgresql.conf?

These proposed editions are per connection. A system-wide config file in /etc that changes defaults for every program would break any program that assumes the old defaults. It also wouldn't solve the problem of having to manually find out what the current recommended defaults are. With editions, you can simply enable the latest one and know you've got the right defaults.

I should have been more clear, I meant a sqlite.conf can configure a program rather than have it apply globally. For example, a config file placed in same directory as its .wal file to tune it for specific instances. That way you don’t need to lookup what “editions” apply which pragmas or settings. With sqlite.conf you can tune your specific database connections by uncommenting the default settings to enable current features/best practices

Re: SQLite should have (Rust-style) editions

#74
post #21

The "use strict" thing is interesting. I often hear people say, well we can't fix absurd behavior in JS because backwards compatibility! Well, we already did, and we can do it again!

"use stricter"

"use strong" was a proposal from Google

https://docs.google.com/document/d/1Qk0qC4s_XNCLemj42FqfsRLp...

Re: SQLite should have (Rust-style) editions

#75
post #21

The "use strict" thing is interesting. I often hear people say, well we can't fix absurd behavior in JS because backwards compatibility! Well, we already did, and we can do it again!

"use strict;" is a perl thing. You also may turn experimental features on, or demand feature set from a certain version.

Re: SQLite should have (Rust-style) editions

#76
post #21

The "use strict" thing is interesting. I often hear people say, well we can't fix absurd behavior in JS because backwards compatibility! Well, we already did, and we can do it again!

"use strict;" is a perl thing. You also may turn experimental features on, or demand feature set from a certain version.

It was (just a perl thing last millennium).. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re: SQLite should have (Rust-style) editions

#77
post #27

SQLite gets so much praise here but when you start using it, you realize quickly how bad it is, the type system is by default very limited and dangerous. It's like comparing old php with a strongly typed language. There is not even a date type...

I agree with you. There are 2 dozen foot-guns to be kept in mind. And discovered a new footgun regarding multi-byte strings and NUL handling today on HN. SQLite became popular because it was the only free and open-source choice 2 decades ago. Now there are other type-safe and robust choices.

Re: SQLite should have (Rust-style) editions

#78
post #3

SQLite is slightly different from Rust in that it is a data container. It’s somewhat more common for people to move SQLite database files from one machine to another and then inspect using the command line tool. And it is often the case that the embedded SQLite version in your app is a newer version than whatever version /usr/bin/sqlite3 happens to be. Adding editions to your SQLite file will probably break this use…

It seems SQLite could be evolve to solve this by just bundling itself entirely in the data files? After all, the binary is less than 1MB, anywhere you’re putting a database surely has at least that much overhead, for most applications it’s less than a drop in the bucket. I’d be interested to learn if there are any db implementations that take this approach, or reasons this wouldn’t work.

There is a way to do this with sqlite in readonly mode using the append vfs [0] which allows you to put your DB appended to the end of the executable, and then the executable can read it (like a zip file the header is then at the end of the db rather than the front). Or you could embed a normal db as a binary blob with the linker. Allowing writes is more tricky because most OSes don't typically allow executables to edit their own executable memory (on unix I believe executables always load as r/x or r/o depending on the region, maybe with some minor exceptions).

And a lot of users of sqlite statically link sqlite within their executable, they actually recommend that instead of dynamically linking.

[0] https://sqlite.org/vfs.html ctrl-f for 'append'

Edit: I got confused between the sqlar command and the append vfs so fixed it.

Re: SQLite should have (Rust-style) editions

#79
post #24

Earlier quoted context omitted.

So for every new SQLite db you want to access would have to run a new untrusted executable? That seems… hilariously bad for security.

Fair point! Was mostly an intrusive technical thought

I mean.... it does sound like a fun project

Re: SQLite should have (Rust-style) editions

#80
post #45

Earlier quoted context omitted.

The "3" refers to the file format (or rather, represents a breaking file format change vs 2), which the devs have committed to keep backward-compatible until 2050. https://sqlite.org/lts.html

It also refers to what the binary on my PATH is called, also what the library name I need to pass to link against it. They even had an sqlite4: https://sqlite.org/src4/doc/trunk/www/design.wiki

Oooh I'd forgotten about that! I'm keen on the real (non-rowid) primary keys and covering indexes. I'm not sure about defaulting to decimal math, but I suppose the reasoning makes sense
Post reply on HN