News for hackers. Stuff that matters.
Re:What If OpenDocument Used SQLite? by miki123211 on Monday September 18, 2023 @09:29AM (#37555812)
The problem with SQLite is that it's not a standardized file format. It's well-documented and pretty well understood for sure, but there's no ISO standard defining how to interpret an SQLite file in excruciating detail. Same goes for competing implementations, Zip and XML have a much smaller API surface than SQLite, whose API, apart from a bunch of C functions, is the SQL language itself. Writing an XML parser is not a trivial task, but it's still simpler than writing an SQL parser, query optimizer, compiler, bytecode VM, full-text search engine, and whatever else Sqlite offers, without any data corruption in the process. If Open Office used SQLite, its programmers would inevitably start using its more esoteric features and writing queries that a less-capable engine wouldn't be able to optimize too well.

This isn't a concern for most software. If you're writing a domain-specific, closed-source application where interoperability with other apps or ISO standardization isn't a concern, SQLite is a perfectly fine file format, but as far as I understand the situation, those concerns did exist for Open Office.

Re:What If OpenDocument Used SQLite? by coliveira on Monday September 18, 2023 @09:45AM (#37556037)
But you don't need a standard, because all interaction between applications and the document is made through SQL. And SQL is standardized (at least the parts that matter). If you have concerns about compatibility, make sure that the document can also be accessed through other databases (like mysql).
Re:What If OpenDocument Used SQLite? by orra on Monday September 18, 2023 @09:48AM (#37556073)
But other databases cannot access sqlite databases, because the file format is internal...
Re:What If OpenDocument Used SQLite? by nojvek on Monday September 18, 2023 @10:08AM (#37556314)
SQL file format is very well documented. In some universities it is an assignment to directly read and write sqllite files from disk and understand the paged and blocks structure.

You don’t need sql for any of it.

https://www.sqlite.org/fileformat.html

Re:What If OpenDocument Used SQLite? by avinassh on Monday September 18, 2023 @01:22PM (#37559099)
> In some universities it is an assignment to directly read and write sqllite files from disk and understand the paged and blocks structure.

do you have any links?

Re:What If OpenDocument Used SQLite? by dunham on Monday September 18, 2023 @02:10PM (#37559752)
It's interesting that this is a classroom assignment, like the sibling comment, I'd curious which university / class this was. I did the read part (+ query planning) on my own as an exercise, but I haven't gotten around to implementing writing yet.

You do need to parse DDL to get the column names, they're stored as a "CREATE TABLE" string. But you don't have to if you want to dump the file without names.

https://github.com/dunhamsteve/sqljs

Re:What If OpenDocument Used SQLite? by bane on Monday September 18, 2023 @09:58AM (#37556202)
Re:What If OpenDocument Used SQLite? by orra on Monday September 18, 2023 @02:04PM (#37559658)
I'll admit, that's a fantastic third party effort. But there definitely isn't the same level of first party support as there is for zip files.
Re:What If OpenDocument Used SQLite? by hot_gril on Monday September 18, 2023 @05:20PM (#37562233)
They can if they want to, using the standard SQLite lib or their own implementation.
Re:What If OpenDocument Used SQLite? by marcinzm on Monday September 18, 2023 @01:57PM (#37559557)
>at least the parts that matter

In my experience every part matters in non-trivial use cases since someone somewhere will use that part.

Re:What If OpenDocument Used SQLite? by gwd on Monday September 18, 2023 @09:49AM (#37556093)
> Writing an XML parser is not a trivial task, but it's still simpler than writing an SQL parser, query optimizer, compiler, bytecode VM, full-text search engine, and whatever else Sqlite offers, without any data corruption in the process.

Just to clarify: You don't actually need to implement all that for it to be a standardized file format, any more than you need to implement all the spreadsheet functionality to be able to read a LibreOffice spreadsheet. All you need to do is to be able to reconstruct the tables. There's no reason, having reconstructed the tables, you couldn't write your own imperative code in the language of your choice to go over them and get whatever information you wanted.

Re:What If OpenDocument Used SQLite? by justin66 on Monday September 18, 2023 @09:59AM (#37556225)
> This isn't a concern for most software.

It's not even a concern for the US Library of Congress, which defined SQLite as a recommended storage format for datasets alongside CSV, XML, and JSON.

Re:What If OpenDocument Used SQLite? by nelgaard on Monday September 18, 2023 @12:35PM (#37558481)
But those are completely different uses of a storage format.

Library of congress considers if someone a 100 years from now could write a new importer in whatever langauge/AI they might use by then.

Office documents are something you send in email attachments to people you often barely know, and expect them to read it in whatever office system they have. And if the recipient uses e.g., Microsoft Word, OFD/Sqlite might not work.

Re:What If OpenDocument Used SQLite? by justin66 on Monday September 18, 2023 @12:54PM (#37558717)
It is true that it requires effort for the developers of a software program to support a given file format. Beyond that I'm not sure what your point is.
Re:What If OpenDocument Used SQLite? by galangalalgol on Monday September 18, 2023 @03:25PM (#37560792)
Not the op, but one point would be, why did we even pick xml, when we had latex and html? Why is a relational database the right tool for a document format?
Re:What If OpenDocument Used SQLite? by cxr on Thursday September 21, 2023 @09:03AM (#37597025)
They're constrained by different requirements. The comment was clear enough:

"those are completely different uses"

It's not a hard concept to grasp. There is no riddle to decipher.

Re:What If OpenDocument Used SQLite? by toast0 on Monday September 18, 2023 @02:44PM (#37560254)
> Office documents are something you send in email attachments to people you often barely know, and expect them to read it in whatever office system they have.

Eh, if they're not running the same office system, down to patches, you can't really expect much.

Re:What If OpenDocument Used SQLite? by bane on Monday September 18, 2023 @10:11AM (#37556353)
I'm not sure if the problem you are pointing out has to do with:

a) SQLite the file format - which is Public Domain and so well documented that parsers for it exist in numerous other languages even though it's almost pointless because...

b) SQLite, the Public Domain (and thus entirely source available) C implementation of the library that can operate on the file format -- and is documented to a level well above what most ISO standards shoot for. It's designed to be used in other software and has bindings for pretty much every major language.

c) Some notional OpenDocument stored in a SQLite file that's really just waiting for somebody to make and document.

ISO standards are great, but if we had to wait for ISO to define a file format we'd have pitifully little to work with.

Re:What If OpenDocument Used SQLite? by joshspankit on Monday September 18, 2023 @10:24AM (#37556511)
Sounds like a solution is to use the C implementation to define the standard and have it canonized in to an ISO.
Re:What If OpenDocument Used SQLite? by belenos46 on Monday September 18, 2023 @10:27AM (#37556559)
Yeah, a solution in search of a problem.
Re:What If OpenDocument Used SQLite? by cornstalks on Monday September 18, 2023 @12:25PM (#37558354)
That's what Opus did. The RFC[1] has a base-64 encoded libopus.tar.gz appendix (Appendix A), which is the "primary normative part of this [Opus] specification." If the prose and source code disagree, the source code takes priority and "wins" when it comes to which is normative.

I have a love-hate relationship with this approach.

[1]: https://datatracker.ietf.org/doc/html/rfc6716

Re:What If OpenDocument Used SQLite? by dfox on Monday September 18, 2023 @12:31PM (#37558435)
That is common for codec standards, the normative part of many MPEG specifications is the parser/decoder in C-like pseudo-code. What is somewhat unique for Xiph is that their normative reference decoders are actually usable.
Re:What If OpenDocument Used SQLite? by Eduard on Monday September 18, 2023 @03:15PM (#37560652)
funny, the RFC even includes a shell command pipeline to extract the base64 out of the awkward RFC formatting.

Using the C source code still leaves room for ambiguities / under-specification, no? After all, the semantics rely on the particular gcc release used for compiling the code.

Re:What If OpenDocument Used SQLite? by cornstalks on Monday September 18, 2023 @04:09PM (#37561328)
There is still the possibility of a bug or under-specification, but that's always the case in any spec. At least with Opus they document what implementation-defined behavior they require, so assuming there aren't any hidden bugs then you should get consistent output across compilers.
Re:What If OpenDocument Used SQLite? by Eduard on Tuesday September 19, 2023 @03:20PM (#37574988)
but the semantics change depending on the build tool version and other factors.
Re:What If OpenDocument Used SQLite? by btilly on Monday September 18, 2023 @02:14PM (#37559835)
It is possible that the C implementation of SQLite is the single most commonly deployed software library ever. If not, then it is probably the second, after zlib.

https://www.sqlite.org/mostdeployed.html

Therefore I consider it a better supported format than most standardized formats.

Re:What If OpenDocument Used SQLite? by lucideer on Monday September 18, 2023 @06:51PM (#37563221)
That page makes the argument for zlib & sqlite, but Daniel Stenberg makes some good points here[0].

My guess would be zlib is still number 1 though, even accounting for Daniel's considerations.

[0] https://daniel.haxx.se/blog/2021/10/21/the-most-used-softwar...

Re:What If OpenDocument Used SQLite? by pl4nty on Monday September 18, 2023 @07:16PM (#37563436)
for one, it's bundled with consumer versions of Windows as winsqlite3.dll. not sure when this started though
Re:What If OpenDocument Used SQLite? by sdeframond on Monday September 18, 2023 @03:18PM (#37560703)
I think this has been discussed before about WebSQL.

> The [WebSQL] specification reached an impasse: all interested implementors have used the same SQL backend (Sqlite), but we need multiple independent implementations to proceed along a standardisation path.

https://www.w3.org/TR/webdatabase/

Re:What If OpenDocument Used SQLite? by sdeframond on Monday September 18, 2023 @03:53PM (#37561110)
The Chrome blog post about deprecating sqlite-based WebSQL makes an interesing point. I believe it applies to OpenDocument as well.

> The Web SQL specification cannot be implemented sustainably, which limits innovation and new functionality. The last version of the standard literally states "User agents must implement the SQL dialect supported by Sqlite 3.6.19". SQLite was not initially designed to run malicious SQL statements, yet implementing Web SQL means browsers have to do exactly this. The need to keep up with security and stability fixes dictates updating SQLite in Chromium. This comes in direct conflict with Web SQL's requirement of behaving exactly as SQLite 3.6.19.

https://developer.chrome.com/blog/deprecating-web-sql/

Re:What If OpenDocument Used SQLite? by bane on Monday September 18, 2023 @07:28PM (#37563590)
In other words, "all the implementors chose a standard, but we're the standard deciders so we're killing the whole idea".
Re:What If OpenDocument Used SQLite? by dragonwriter on Monday September 18, 2023 @07:40PM (#37563734)
One problem was the standard was bug-for-bug replication of a particular version of SQLite.

There’s very good reason for that not to be a standard. (Now, assuming the SQLite documentation is licensed in a way which supports this, copying the documentation of SQLite’s supported SQL as of that version into the standard might have been viable, but no one interested in having WebSQL proposed that or any other resolution.

That relates to the cited issue of absence of independent implementations, which would have been a problem even with a spec that supported independent implementations and verification of their compliance independent of a particular reference implementation. though I personally think the spec problem is a bigger real problem (even if not the decisive policy problem) than the “everyone is using the same underlying software to implement the spec” problem is in this case, where the shared implementation is a permissively licensed open source implementation sponsored by several of the browser vendors, among others.

Re:What If OpenDocument Used SQLite? by bane on Monday September 18, 2023 @08:27PM (#37564193)
hmmm...I appreciate the thoughtful reply. You bring up an interesting point. What is the SQLite documentation licensed as? I would assume PD like the rest of it, but I don't know that for sure.
Re:What If OpenDocument Used SQLite? by anticensor on Tuesday September 19, 2023 @03:46PM (#37575401)
SQLite itself is in the public domain.
Re:What If OpenDocument Used SQLite? by sdeframond on Tuesday September 19, 2023 @02:23AM (#37566244)
The standard deciders are the implementors. There is no point in opposing them. The W3C is actually the representatives of Google, Mozilla, Microsoft, Opera and so on.
Re:What If OpenDocument Used SQLite? by zie on Monday September 18, 2023 @05:38PM (#37562434)
Re:What If OpenDocument Used SQLite? by paulddraper on Monday September 18, 2023 @11:05AM (#37557141)
> less capable engine

There wouldn't be another engine.

It would be SQLite. Period.

Re:What If OpenDocument Used SQLite? by cryptonector on Monday September 18, 2023 @11:53AM (#37557905)
This could have been used as an opportunity to standardize the SQLite3 DB file format.
Re:What If OpenDocument Used SQLite? by sethev on Monday September 18, 2023 @12:07PM (#37558118)
You seem to be mixing up the file format with how it's used. An application that uses SQLite's file format would use SQLite's library as part of the application. Yes, it would be quite a lot of work to replicate that library but in the same way that replicating the code that uses OpenDocument's file format would be.

The file format itself is pretty straightforward.

Re:What If OpenDocument Used SQLite? by jimbokun on Monday September 18, 2023 @02:15PM (#37559847)
Just define the schema and the semantics of each column for each table.
Re:What If OpenDocument Used SQLite? by patapong on Monday September 18, 2023 @02:45PM (#37560265)
This sounds exactly like the argument that killed WebSQL in 2010: https://en.wikipedia.org/wiki/Web_SQL_Database

I am still salty about this, as WebSQL would have made it much easier to build a certain class of web apps.

Re:What If OpenDocument Used SQLite? by bb010g on Monday September 18, 2023 @06:25PM (#37562955)
Re:What If OpenDocument Used SQLite? by hot_gril on Monday September 18, 2023 @05:14PM (#37562153)
I've never seen this as a problem, since plenty of random things are distributed as sqlite files. All the remaining questions for ODF would be about the schema design.
Re:What If OpenDocument Used SQLite? by eternityforest on Tuesday September 19, 2023 @02:41AM (#37566388)
It almost seems worth giving up ISO for SQLite, but I understand there are real concerns when you get into enterprisy stuff.

SQLite is kind of its own standard. It's public domain and they don't do breaking changes all day, and it's in C. As long as C is still viable, SQLite is usable on basically all non embedded platforms, and nobody really needs to reimplement it, unless they want to port it to Rust or something.

Not that you'd need to, since it's already very reliable.