Skip to content

Commit a36d72c

Browse files
committed
Stricter vtabs, sqlite-createtable-parser.
1 parent e7f5604 commit a36d72c

18 files changed

Lines changed: 58 additions & 446 deletions

File tree

embed/bcw2/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ cd ~-
6666

6767
"$BINARYEN/wasm-ctor-eval" -g -c _initialize bcw2.wasm -o bcw2.tmp
6868
"$BINARYEN/wasm-opt" -g bcw2.tmp -o bcw2.wasm \
69-
--low-memory-unused --gufa --generate-global-effects --converge -O3 \
69+
--gufa --generate-global-effects --low-memory-unused --converge -O3 \
7070
--enable-mutable-globals --enable-nontrapping-float-to-int \
7171
--enable-simd --enable-bulk-memory --enable-sign-ext \
7272
--enable-reference-types --enable-multivalue \

embed/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ trap 'rm -f sqlite3.tmp' EXIT
2929

3030
"$BINARYEN/wasm-ctor-eval" -g -c _initialize sqlite3.wasm -o sqlite3.tmp
3131
"$BINARYEN/wasm-opt" -g sqlite3.tmp -o sqlite3.wasm \
32-
--low-memory-unused --gufa --generate-global-effects --converge -O3 \
32+
--gufa --generate-global-effects --low-memory-unused --converge -O3 \
3333
--enable-mutable-globals --enable-nontrapping-float-to-int \
3434
--enable-simd --enable-bulk-memory --enable-sign-ext \
3535
--enable-reference-types --enable-multivalue \
36-
--strip --strip-producers
36+
--strip --strip-producers

ext/bloom/bloom.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ func connect(db *sqlite3.Conn, _, schema, table string, arg ...string) (_ *bloom
120120
return nil, err
121121
}
122122

123-
load, _, err := db.Prepare(fmt.Sprintf(
123+
load, _, err := db.PrepareFlags(fmt.Sprintf(
124124
`SELECT m/8, p, k FROM %s.%s WHERE rowid = 1`,
125-
sqlite3.QuoteIdentifier(b.schema), sqlite3.QuoteIdentifier(b.storage)))
125+
sqlite3.QuoteIdentifier(b.schema), sqlite3.QuoteIdentifier(b.storage)),
126+
sqlite3.PREPARE_DONT_LOG)
126127
if err != nil {
127128
return nil, err
128129
}
@@ -165,9 +166,10 @@ func (t *bloom) ShadowTables() {
165166
}
166167

167168
func (t *bloom) Integrity(schema, table string, flags int) error {
168-
load, _, err := t.db.Prepare(fmt.Sprintf(
169+
load, _, err := t.db.PrepareFlags(fmt.Sprintf(
169170
`SELECT typeof(data), length(data), p, n, m, k FROM %s.%s WHERE rowid = 1`,
170-
sqlite3.QuoteIdentifier(t.schema), sqlite3.QuoteIdentifier(t.storage)))
171+
sqlite3.QuoteIdentifier(t.schema), sqlite3.QuoteIdentifier(t.storage)),
172+
sqlite3.PREPARE_DONT_LOG)
171173
if err != nil {
172174
return fmt.Errorf("bloom: %v", err) // can't wrap!
173175
}

ext/closure/closure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
202202
sqlite3.QuoteIdentifier(column),
203203
sqlite3.QuoteIdentifier(parent),
204204
)
205-
stmt, _, err := c.db.Prepare(sql)
205+
stmt, _, err := c.db.PrepareFlags(sql, sqlite3.PREPARE_DONT_LOG)
206206
if err != nil {
207207
return err
208208
}

ext/csv/csv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func RegisterFS(db *sqlite3.Conn, fsys fs.FS) error {
100100
}
101101
schema = getSchema(header, columns, row)
102102
} else {
103-
t.typs, err = getColumnAffinities(schema)
103+
t.typs, err = getColumnAffinities(db, schema)
104104
if err != nil {
105105
return nil, err
106106
}

ext/csv/types.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package csv
33
import (
44
"strings"
55

6+
"github.com/ncruces/go-sqlite3"
7+
"github.com/ncruces/go-sqlite3/internal/util"
68
"github.com/ncruces/go-sqlite3/util/sql3util"
79
)
810

@@ -16,7 +18,17 @@ const (
1618
real affinity = 4
1719
)
1820

19-
func getColumnAffinities(schema string) ([]affinity, error) {
21+
func getColumnAffinities(db *sqlite3.Conn, schema string) ([]affinity, error) {
22+
stmt, tail, err := db.PrepareFlags(schema,
23+
sqlite3.PREPARE_DONT_LOG|sqlite3.PREPARE_NO_VTAB|sqlite3.PREPARE_FROM_DDL)
24+
if err != nil {
25+
return nil, err
26+
}
27+
stmt.Close()
28+
if tail != "" {
29+
return nil, util.TailErr
30+
}
31+
2032
tab, err := sql3util.ParseTable(schema)
2133
if err != nil {
2234
return nil, err

ext/pivot/pivot.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ func declare(db *sqlite3.Conn, _, _, _ string, arg ...string) (ret *table, err e
4747
if err != nil {
4848
return nil, err
4949
}
50+
defer stmt.Close()
5051
if tail != "" {
5152
return nil, util.TailErr
5253
}
53-
defer stmt.Close()
5454

5555
t.keys = make([]string, stmt.ColumnCount())
5656
for i := range t.keys {
@@ -196,7 +196,9 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
196196
return err
197197
}
198198

199-
c.scan, _, err = c.table.db.PrepareFlags(idxStr, sqlite3.PREPARE_FROM_DDL)
199+
const prepflags = sqlite3.PREPARE_DONT_LOG | sqlite3.PREPARE_FROM_DDL
200+
201+
c.scan, _, err = c.table.db.PrepareFlags(idxStr, prepflags)
200202
if err != nil {
201203
return err
202204
}
@@ -208,7 +210,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
208210
}
209211

210212
if c.cell == nil {
211-
c.cell, _, err = c.table.db.PrepareFlags(c.table.cell, sqlite3.PREPARE_PERSISTENT|sqlite3.PREPARE_FROM_DDL)
213+
c.cell, _, err = c.table.db.PrepareFlags(c.table.cell, prepflags)
212214
if err != nil {
213215
return err
214216
}

ext/statement/stmt.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ func declare(db *sqlite3.Conn, _, _, _ string, arg ...string) (*table, error) {
3535

3636
sql := "SELECT * FROM\n" + arg[0]
3737

38-
stmt, tail, err := db.PrepareFlags(sql, sqlite3.PREPARE_PERSISTENT|sqlite3.PREPARE_FROM_DDL)
38+
stmt, tail, err := db.PrepareFlags(sql,
39+
sqlite3.PREPARE_PERSISTENT|sqlite3.PREPARE_FROM_DDL)
3940
if err != nil {
4041
return nil, err
4142
}
4243
if tail != "" {
44+
stmt.Close()
4345
return nil, util.TailErr
4446
}
4547

@@ -132,7 +134,8 @@ func (t *table) Open() (_ sqlite3.VTabCursor, err error) {
132134
if !t.inuse {
133135
t.inuse = true
134136
} else {
135-
stmt, _, err = t.stmt.Conn().PrepareFlags(t.sql, sqlite3.PREPARE_FROM_DDL)
137+
stmt, _, err = t.stmt.Conn().PrepareFlags(t.sql,
138+
sqlite3.PREPARE_DONT_LOG|sqlite3.PREPARE_FROM_DDL)
136139
if err != nil {
137140
return nil, err
138141
}

sqlite3/libc/build.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ EOF
3939
-Wl,--export=strcspn \
4040
-Wl,--export=strlen \
4141
-Wl,--export=strrchr \
42-
-Wl,--export=strspn \
43-
-Wl,--export=qsort
42+
-Wl,--export=strspn
4443

4544
"$BINARYEN/wasm-ctor-eval" -g -c _initialize libc.wasm -o libc.tmp
46-
"$BINARYEN/wasm-opt" -g libc.tmp -o libc.wasm \
47-
--low-memory-unused --generate-global-effects --converge -O3 \
45+
"$BINARYEN/wasm-opt" -g libc.tmp -o libc.wasm --converge -O3 \
4846
--enable-mutable-globals --enable-nontrapping-float-to-int \
4947
--enable-simd --enable-bulk-memory --enable-sign-ext \
5048
--enable-reference-types --enable-multivalue \

sqlite3/libc/libc.wasm

-534 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)