Commit 15ca5030 authored by cznic's avatar cznic
Browse files

licensing: ship the sqlite-vec MIT notice, normalize the license names

vec/ has carried the transpiled sqlite-vec sources since v1.47.0, but the
module shipped only its own BSD-3-Clause LICENSE and the public-domain SQLite
notice. sqlite-vec is Copyright (c) 2024 Alex Garcia and dual-licensed
Apache-2.0 OR MIT; modernc.org/libsqlite_vec's generator elects MIT, whose
terms require the copyright and permission notice to accompany substantial
portions of the software. 2.8 MB of transpiled vec/ is a substantial portion.
Attribution was never absent -- vec's package documentation names the
extension, pins v0.1.9 and links upstream -- but the license text was.

LICENSE-SQLITE_VEC: the notice, byte-identical to LICENSE-MIT in the upstream
v0.1.9 archive and to the file libsqlite_vec extracts it into.

vendor_libs/main.go: the omission was mechanical -- the tool copied the
per-target transpiles and nothing else, so a plain cp of the notice would have
survived only until the next `make vendor`. Copy it alongside the sources it
belongs to, and treat a missing source as fatal: shipping the code without the
notice is worse than not vendoring at all.

SQLITE-LICENSE -> LICENSE-SQLITE, contents unchanged. This matches the new file
beside it and the LICENSE-<upstream> convention the rest of the modernc.org
repositories follow, but it is not only cosmetic. `go mod vendor` picks the
metadata files it copies into a downstream vendor/ tree by matching each name
against a fixed prefix list (cmd/go/internal/modcmd/vendor.go, metaPrefixes)
that includes LICENSE, so a name merely ending in LICENSE was never propagated.
Both notices now reach vendored builds, which is where the MIT terms on vec/
keep applying. Direct links to the old path will break.

vec/patches.go: a License section on the package documentation, so an importer
of vec sees on pkg.go.dev that this package is under a different license from
the rest of the module.

Found by an SBOM audit of the published module.

Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
parent 69cd3ca1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@
     - Add an opt-in `_defensive` DSN query parameter that turns on SQLite's defensive mode for the connection, disabling the SQL-level features that let ordinary statements deliberately corrupt the database file. When `_defensive=1` (or any `strconv.ParseBool` true value) is supplied, the driver calls `sqlite3_db_config` with `SQLITE_DBCONFIG_DEFENSIVE` immediately after `sqlite3_open_v2` and before every other parameter is applied, so the PRAGMAs the driver itself runs, the `_pragma` list, and every statement the caller prepares are all subject to it. On such a connection `PRAGMA writable_schema=ON`, `PRAGMA journal_mode=OFF` and `PRAGMA schema_version=N` become silent no-ops, and writes to a virtual table's shadow tables (fts5's `_data`, `_idx` and so on) and to `sqlite_dbpage` fail with "table ... may not be modified"; reading those tables, ordinary use of the virtual tables that own them, and `VACUUM` are unaffected. The flag has no PRAGMA equivalent, so `sqlite3_db_config` — and therefore a DSN parameter — is the only way to reach it short of dropping to `modernc.org/sqlite/lib`. The value is parsed before `sqlite3_open_v2`, so an invalid one fails the connection without creating the database file, and the parameter must appear at most once: a repeated `_defensive` is an error rather than letting the first value silently win. Absence of the parameter, or `_defensive=0`, leaves SQLite's default behavior unchanged; existing DSNs continue to work byte-for-byte. Two limits are worth stating plainly, since the name invites more confidence than the flag earns. Defensive mode is a hardening measure, not a sandbox for hostile database files: it is one of several steps [SQLite recommends](https://www.sqlite.org/security.html) for that purpose, and this build compiles with neither `SQLITE_TRUSTED_SCHEMA=0` nor `SQLITE_DQS=0` and exposes no authorizer. And it is a property of the connection, not of the database file — a second handle opened on the same file without the parameter is unrestricted.
     - Reject the one DSN combination defensive mode would otherwise swallow in silence. `_defensive=1` together with `_journal_mode=OFF` (or `_journal=OFF`) now fails the connection instead of opening one in which neither parameter was honoured: SQLite turns `PRAGMA journal_mode=OFF` into a no-op that still reports success, so the driver would have accepted the mode, executed it, and left the journal untouched without telling anyone. The check runs in the validation phase introduced in v1.55.0, before any statement executes, so a rejected DSN cannot leave the database half-configured. `_pragma` remains the exception it has always been: `_pragma=journal_mode(OFF)` alongside `_defensive=1` still runs and is still silently ignored by SQLite. Only DSNs using `_defensive` can be affected, and that parameter is new, so no DSN that opened before changes behavior.
     - See [GitHub pull request #6](https://github.com/modernc-org/sqlite/pull/6), thanks wsman!
     - Ship the sqlite-vec license notice this module has been missing. `modernc.org/sqlite/vec` has bundled the transpiled [sqlite-vec](https://github.com/asg017/sqlite-vec) sources since v1.47.0, but the module carried only its own BSD-3-Clause `LICENSE` and the public-domain SQLite notice. sqlite-vec is Copyright (c) 2024 Alex Garcia, dual-licensed Apache-2.0 OR MIT and used here under MIT, whose terms require the copyright and permission notice to accompany substantial portions of the software — which 2.8 MB of transpiled `vec/` plainly is. The notice now ships as `LICENSE-SQLITE_VEC` in the module root, byte-identical to the `LICENSE-MIT` in the upstream v0.1.9 archive and named after the file `modernc.org/libsqlite_vec` extracts it into. Attribution was never absent — `vec`'s package documentation has named the extension, pinned the version and linked upstream — but the license text itself was, and the omission was ours: `vendor_libs/main.go` copied the per-target transpiles and nothing else. It now copies the notice alongside them and fails the vendoring run if it cannot, so a `make vendor` can no longer quietly drop it. The `vec` package documentation gained a License section recording that the package is under a different license from the rest of this module.
     - **The SQLite notice is renamed from `SQLITE-LICENSE` to `LICENSE-SQLITE`**; update any direct links to it. Its contents are unchanged and SQLite remains public domain. The name now matches both the new `LICENSE-SQLITE_VEC` beside it and the `LICENSE-<upstream>` convention every other modernc.org repository follows, but it is more than cosmetic: `go mod vendor` selects the files it copies into a downstream `vendor/` tree by matching each name against a fixed list of prefixes — `LICENSE` among them — so a name merely *ending* in `LICENSE` was never propagated. Both bundled notices now travel with the code into vendored builds, which is where the MIT terms on `vec/` keep applying. No code changes; no behavior changes.

 - 2026-08-03 v1.56.0:
     - Re-vendor the transpiled SQLite sources, picking up `modernc.org/libsqlite3`'s fix for an upstream **data-corruption bug in SQLite 3.53.3's journal rollback**. The SQLite version is unchanged at [3.53.3](https://sqlite.org/releaselog/3_53_3.html); what changes is that the amalgamation is now patched before it is transpiled. 3.53.3 reworked `readSuperJournal()` to return the super-journal name through a `char**` out-parameter, and `pager_playback()` now tests that pointer where it used to test `zSuper[0]`. A crash during the commit of a multi-database (ATTACH) transaction can leave the super-journal name and its checksum zeroed while the name length and the trailing magic survive; the checksum is a plain byte sum, so an all-zero name still validates and `readSuperJournal()` hands back a non-NULL pointer to an empty string. `pager_playback()` then calls `sqlite3OsAccess(pVfs, "", SQLITE_ACCESS_EXISTS)`, gets ENOENT, and deletes the hot journal without playing it back — leaving the database corrupted. This is not a transpilation artifact: a plain gcc build of the stock 3.53.3 amalgamation fails on the same bytes while 3.53.2 recovers them, and it is what has been making upstream's own `test/crash.test` fail intermittently, in roughly 2% of runs, on every platform. The patch restores the pre-3.53.3 behaviour of reporting a `(nul)` super-journal name and will be dropped once upstream ships its own fix. Every supported target carries it.
+0 −0

File moved.

LICENSE-SQLITE_VEC

0 → 100644
+21 −0
Original line number Diff line number Diff line
MIT License

Copyright (c) 2024 Alex Garcia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+9 −0
Original line number Diff line number Diff line
@@ -20,6 +20,15 @@
// available:
//
//	CREATE VIRTUAL TABLE vec_examples USING vec0(embedding float[8])
//
// # License
//
// sqlite-vec is Copyright (c) 2024 Alex Garcia and is dual-licensed Apache-2.0
// OR MIT; it is used here under the MIT license. That is a different license
// from the rest of this module -- SQLite itself is public domain and this
// module's own code is BSD-3-Clause -- and the MIT notice must accompany
// redistribution of the sources in this package. It travels with them as
// LICENSE-SQLITE_VEC in the module root.
package vec

import (
+20 −0
Original line number Diff line number Diff line
@@ -139,6 +139,26 @@ type Sqlite3_vtab_cursor = sqlite3_vtab_cursor
	}

	{
		// Unlike SQLite, which is public domain, sqlite-vec is MIT-licensed and
		// its notice must travel with the substantial portion of it vendored
		// below. modernc.org/libsqlite_vec's generator extracts the notice from
		// the upstream tarball as LICENSE-SQLITE_VEC; copy it verbatim next to
		// this module's own LICENSE. Read errors are fatal on purpose: shipping
		// the code without the notice is worse than not vendoring at all.
		{
			const licenseFile = "LICENSE-SQLITE_VEC"
			ifn := filepath.Join("..", "libsqlite_vec", licenseFile)
			fmt.Printf("license\t%s\n", ifn)
			license, err := os.ReadFile(ifn)
			if err != nil {
				fail(1, "%s\n", err)
			}

			if err := os.WriteFile(licenseFile, license, 0660); err != nil {
				fail(1, "%s\n", err)
			}
		}

		for _, v := range []struct{ goos, goarch string }{
			{"darwin", "amd64"},
			{"darwin", "arm64"},