Skip to content

Commit 5de2f48

Browse files
committed
Switch core catalog to ncruces/go-sqlite3
The analysis core was the last user of modernc.org/sqlite; every other SQLite path (vet, the sqlite engine analyzer, sqlite3ext, sqltest) already uses ncruces/go-sqlite3, which as of v0.35 is wasm2go-generated pure Go with no wazero runtime. Using one driver drops the entire modernc dependency tree and the second embedded copy of SQLite. Serialization goes through the driver's Raw() escape hatch and ext/serdes instead of modernc's Serialize method. ncruces compiles SQLite with SQLITE_DEFAULT_FOREIGN_KEYS=1, unlike stock SQLite and modernc. Enforcement surfaced a dangling return_type_oid in the dolphin seed (UNHEX declares no return type), so the catalog now pins foreign_keys=OFF explicitly, preserving the previous behavior where the schema's foreign keys are documentation. Benchmarks (internal/core/analyzer, n=10, benchstat) show ncruces slower than modernc on this workload: CatalogNew 2.625m ± 3% 2.767m ± 3% +5.39% (p=0.000) ApplySchema 2.953m ± 3% 3.212m ± 7% +8.76% (p=0.000) Prepare 315.0µ ± 1% 359.6µ ± 8% +14.15% (p=0.000) geomean 1.347m 1.473m +9.38% Allocations drop ~3.4% but CPU time is up across the board, trading single-digit analysis overhead for a single SQLite implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J3BkQjNzN54dXhs3M1ypGr
1 parent 692b624 commit 5de2f48

4 files changed

Lines changed: 22 additions & 67 deletions

File tree

go.mod

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,19 @@ require (
3030
google.golang.org/grpc v1.83.0
3131
google.golang.org/protobuf v1.36.11
3232
gopkg.in/yaml.v3 v3.0.1
33-
modernc.org/sqlite v1.55.0
3433
)
3534

3635
require (
3736
cel.dev/expr v0.25.2 // indirect
3837
filippo.io/edwards25519 v1.2.0 // indirect
3938
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
40-
github.com/dustin/go-humanize v1.0.1 // indirect
41-
github.com/google/uuid v1.6.0 // indirect
4239
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4340
github.com/jackc/pgpassfile v1.0.0 // indirect
4441
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
4542
github.com/jackc/puddle/v2 v2.2.2 // indirect
4643
github.com/kr/text v0.2.0 // indirect
47-
github.com/mattn/go-isatty v0.0.20 // indirect
4844
github.com/ncruces/go-sqlite3-wasm/v3 v3.2.35303 // indirect
49-
github.com/ncruces/go-strftime v1.0.0 // indirect
5045
github.com/ncruces/julianday v1.0.0 // indirect
51-
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
5246
github.com/rogpeppe/go-internal v1.10.0 // indirect
5347
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
5448
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
@@ -60,7 +54,4 @@ require (
6054
golang.org/x/text v0.39.0 // indirect
6155
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
6256
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect
63-
modernc.org/libc v1.74.1 // indirect
64-
modernc.org/mathutil v1.7.1 // indirect
65-
modernc.org/memory v1.11.0 // indirect
6657
)

go.sum

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ github.com/cubicdaiya/gonp v1.0.4/go.mod h1:iWGuP/7+JVTn02OWhRemVbMmG1DOUnmrGTYY
1313
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1414
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1515
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
16-
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
17-
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
1816
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
1917
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
2018
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
@@ -29,12 +27,8 @@ github.com/google/cel-go v0.30.0 h1:ll54AkzKunWkBn9wSoiUXbFZXYZTkdJGNXTBXUoolGo=
2927
github.com/google/cel-go v0.30.0/go.mod h1:X0bD6iVNR8pkROSOoHVdgTkzmRcosof7WQqCD6wcMc8=
3028
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
3129
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
32-
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
33-
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
3430
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
3531
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
36-
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
37-
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
3832
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
3933
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
4034
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
@@ -53,22 +47,16 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
5347
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
5448
github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ=
5549
github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=
56-
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
57-
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
5850
github.com/ncruces/go-sqlite3 v0.35.2 h1:YOoumI7tkxMIm1MBrkucRb1qtvAPEh8RrZtv6U+2aLs=
5951
github.com/ncruces/go-sqlite3 v0.35.2/go.mod h1:lVlozMCF6VGdI1FOgl0pBfMviw6DIh/QIMKQyjmg2ac=
6052
github.com/ncruces/go-sqlite3-wasm/v3 v3.2.35303 h1:td8kMW1bWwzc7NnlzPjQV4GbDNLkje8htGBfbZRaSh8=
6153
github.com/ncruces/go-sqlite3-wasm/v3 v3.2.35303/go.mod h1:o8gr9w/50fXA5TDskg6bNUjvqmFfw4KaXth4q+yDSjg=
62-
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
63-
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
6454
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
6555
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
6656
github.com/pganalyze/pg_query_go/v6 v6.2.2 h1:O0L6zMC226R82RF3X5n0Ki6HjytDsoAzuzp4ATVAHNo=
6757
github.com/pganalyze/pg_query_go/v6 v6.2.2/go.mod h1:Cn6+j4870kJz3iYNsb0VsNG04vpSWgEvBwc590J4qD0=
6858
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6959
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
70-
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
71-
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
7260
github.com/riza-io/grpc-go v0.2.0 h1:2HxQKFVE7VuYstcJ8zqpN84VnAoJ4dCL6YFhJewNcHQ=
7361
github.com/riza-io/grpc-go v0.2.0/go.mod h1:2bDvR9KkKC3KhtlSHfR3dAXjUMT86kg4UfWFyVGWqi8=
7462
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
@@ -120,19 +108,14 @@ go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
120108
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
121109
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
122110
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
123-
golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=
124-
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
125111
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
126112
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
127113
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
128114
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
129-
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
130115
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
131116
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
132117
golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus=
133118
golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM=
134-
golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q=
135-
golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA=
136119
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
137120
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
138121
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa h1:Kjn0N0tCrDgiAFW+lGO4JZ3ck44CehvJQMAwj9QF0G8=
@@ -149,31 +132,3 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
149132
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
150133
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
151134
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
152-
modernc.org/cc/v4 v4.29.0 h1:CXgwL8cvxmyzBQZzbSl/6xFtMCryb6u8IOqDci39cgc=
153-
modernc.org/cc/v4 v4.29.0/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
154-
modernc.org/ccgo/v4 v4.34.6 h1:sBgfIwyN0TQ9C5hwIeuqyeAKyMWnbvj2fvpF4L11uzU=
155-
modernc.org/ccgo/v4 v4.34.6/go.mod h1:SZ8YcN9NG7XVsQYdm6jYBvi8PQP1qi+kqB6OhjqI3Fk=
156-
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
157-
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
158-
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
159-
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
160-
modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=
161-
modernc.org/gc/v3 v3.1.4/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
162-
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
163-
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
164-
modernc.org/libc v1.74.1 h1:bdR4VTKFMC4966QSNZ05XLGI/VwzVa2kTUX51Dm0riQ=
165-
modernc.org/libc v1.74.1/go.mod h1:uH4t5bOx3G3g9Xcmj10YKlTcVISlRDwv8VoQJG9n8Os=
166-
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
167-
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
168-
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
169-
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
170-
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
171-
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
172-
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
173-
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
174-
modernc.org/sqlite v1.55.0 h1:hIFh0MCH0rGinQ/4KYb5/UbCkRkb+UP+OkLCVWa5MTM=
175-
modernc.org/sqlite v1.55.0/go.mod h1:4ntCLuNmnH8+GNqjka1wNg7KJd5/Hi5FYp8K+XQ7GZw=
176-
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
177-
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
178-
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
179-
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=

internal/core/cache.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ import (
77
"fmt"
88
"log/slog"
99

10+
"github.com/ncruces/go-sqlite3"
11+
"github.com/ncruces/go-sqlite3/ext/serdes"
12+
1013
"github.com/sqlc-dev/sqlc/internal/cache"
1114
"github.com/sqlc-dev/sqlc/internal/core/catalogdb"
1215
)
1316

1417
// The name of the sole output blob a CoreCatalog action produces.
1518
const catalogOutput = "catalog.db"
1619

17-
// serializer is the driver's serialization API, which the SQLite driver
18-
// implements on its connections.
19-
type serializer interface {
20-
Serialize() ([]byte, error)
20+
// rawConn is the driver's escape hatch to the SQLite connection underneath a
21+
// database/sql connection, which the serialization API needs.
22+
type rawConn interface {
23+
Raw() *sqlite3.Conn
2124
}
2225

2326
// NewCached returns the catalog a dialect and a schema produce, restored from
@@ -131,9 +134,9 @@ func save(store *cache.Cache, action cache.Digest, cat *Catalog) error {
131134
// written to disk as, which is what gets stored.
132135
func serialize(db *sql.DB) ([]byte, error) {
133136
var blob []byte
134-
err := withRawConn(db, func(s serializer) error {
137+
err := withRawConn(db, func(c *sqlite3.Conn) error {
135138
var err error
136-
blob, err = s.Serialize()
139+
blob, err = serdes.Serialize(c, "main")
137140
return err
138141
})
139142
if err != nil {
@@ -142,17 +145,17 @@ func serialize(db *sql.DB) ([]byte, error) {
142145
return blob, nil
143146
}
144147

145-
func withRawConn(db *sql.DB, fn func(serializer) error) error {
148+
func withRawConn(db *sql.DB, fn func(*sqlite3.Conn) error) error {
146149
conn, err := db.Conn(context.Background())
147150
if err != nil {
148151
return err
149152
}
150153
defer conn.Close()
151154
return conn.Raw(func(driverConn any) error {
152-
s, ok := driverConn.(serializer)
155+
r, ok := driverConn.(rawConn)
153156
if !ok {
154-
return fmt.Errorf("driver does not serialize databases")
157+
return fmt.Errorf("driver does not expose its SQLite connection")
155158
}
156-
return fn(s)
159+
return fn(r.Raw())
157160
})
158161
}

internal/core/catalog.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/sqlc-dev/sqlc/internal/core/catalogdb"
1010
"github.com/sqlc-dev/sqlc/internal/core/catalogdef"
1111

12-
_ "modernc.org/sqlite"
12+
_ "github.com/ncruces/go-sqlite3/driver"
1313
)
1414

1515
//go:generate go run github.com/sqlc-dev/sqlc/cmd/sqlc generate
@@ -70,7 +70,7 @@ func New(opts ...Option) (*Catalog, error) {
7070
// told as much, which lets any number of processes share it with no locking
7171
// and no copy.
7272
func openFile(path string) (*sql.DB, error) {
73-
db, err := sql.Open("sqlite", "file:"+path+"?mode=ro&immutable=1")
73+
db, err := sql.Open("sqlite3", "file:"+path+"?mode=ro&immutable=1")
7474
if err != nil {
7575
return nil, fmt.Errorf("core: open catalog %s: %w", path, err)
7676
}
@@ -95,17 +95,23 @@ func pinPool(db *sql.DB) {
9595

9696
// openDB opens the empty SQLite database a catalog is built in.
9797
func openDB() (*sql.DB, error) {
98-
db, err := sql.Open("sqlite", ":memory:")
98+
db, err := sql.Open("sqlite3", ":memory:")
9999
if err != nil {
100100
return nil, fmt.Errorf("core: open catalog: %w", err)
101101
}
102102
pinPool(db)
103103

104104
// The catalog being built is scratch state that is never read back from
105105
// disk, so durability buys nothing and costs a journal write per statement.
106+
// Foreign keys are declared in the schema as documentation but not
107+
// enforced: dialect seeds carry dangling references (a proc whose return
108+
// type was never registered), and enforcement would also charge an index
109+
// lookup per seeded row. The driver compiles SQLite with enforcement on by
110+
// default, so it is switched off explicitly.
106111
for _, pragma := range []string{
107112
"PRAGMA journal_mode = OFF",
108113
"PRAGMA synchronous = OFF",
114+
"PRAGMA foreign_keys = OFF",
109115
} {
110116
if _, err := db.Exec(pragma); err != nil {
111117
db.Close()

0 commit comments

Comments
 (0)