diff --git a/ext/stats/percentile.go b/ext/stats/percentile.go index dafd339..c60ca22 100644 --- a/ext/stats/percentile.go +++ b/ext/stats/percentile.go @@ -28,11 +28,13 @@ type percentile struct { } func (q *percentile) Step(ctx sqlite3.Context, arg ...sqlite3.Value) { - if a := arg[0]; a.NumericType() != sqlite3.NULL { - q.nums = append(q.nums, a.Float()) + a := arg[0] + f := a.Float() + if f != 0.0 || a.NumericType() != sqlite3.NULL { + q.nums = append(q.nums, f) } - if q.kind != median { - q.arg1 = append(q.arg1[:0], arg[1].RawText()...) + if q.kind != median && q.arg1 == nil { + q.arg1 = append(q.arg1, arg[1].RawText()...) } } diff --git a/ext/stats/stats.go b/ext/stats/stats.go index f16423d..cddbffa 100644 --- a/ext/stats/stats.go +++ b/ext/stats/stats.go @@ -121,14 +121,18 @@ func (fn *variance) Value(ctx sqlite3.Context) { } func (fn *variance) Step(ctx sqlite3.Context, arg ...sqlite3.Value) { - if a := arg[0]; a.NumericType() != sqlite3.NULL { - fn.enqueue(a.Float()) + a := arg[0] + f := a.Float() + if f != 0.0 || a.NumericType() != sqlite3.NULL { + fn.enqueue(f) } } func (fn *variance) Inverse(ctx sqlite3.Context, arg ...sqlite3.Value) { - if a := arg[0]; a.NumericType() != sqlite3.NULL { - fn.dequeue(a.Float()) + a := arg[0] + f := a.Float() + if f != 0.0 || a.NumericType() != sqlite3.NULL { + fn.dequeue(f) } } @@ -178,14 +182,22 @@ func (fn *covariance) Value(ctx sqlite3.Context) { func (fn *covariance) Step(ctx sqlite3.Context, arg ...sqlite3.Value) { b, a := arg[1], arg[0] // avoid a bounds check - if a.NumericType() != sqlite3.NULL && b.NumericType() != sqlite3.NULL { - fn.enqueue(a.Float(), b.Float()) + fa := a.Float() + fb := b.Float() + if true && + (fa != 0.0 || a.NumericType() != sqlite3.NULL) && + (fb != 0.0 || b.NumericType() != sqlite3.NULL) { + fn.enqueue(fa, fb) } } func (fn *covariance) Inverse(ctx sqlite3.Context, arg ...sqlite3.Value) { b, a := arg[1], arg[0] // avoid a bounds check - if a.NumericType() != sqlite3.NULL && b.NumericType() != sqlite3.NULL { - fn.dequeue(a.Float(), b.Float()) + fa := a.Float() + fb := b.Float() + if true && + (fa != 0.0 || a.NumericType() != sqlite3.NULL) && + (fb != 0.0 || b.NumericType() != sqlite3.NULL) { + fn.dequeue(fa, fb) } } diff --git a/sqlite3/bind.c b/sqlite3/bind.c index 254c232..bce1177 100644 --- a/sqlite3/bind.c +++ b/sqlite3/bind.c @@ -2,12 +2,12 @@ #include "sqlite3.h" -int sqlite3_bind_text_go(sqlite3_stmt* stmt, int i, const char* zData, +int sqlite3_bind_text_go(sqlite3_stmt *stmt, int i, const char *zData, sqlite3_uint64 nData) { return sqlite3_bind_text64(stmt, i, zData, nData, &sqlite3_free, SQLITE_UTF8); } -int sqlite3_bind_blob_go(sqlite3_stmt* stmt, int i, const char* zData, +int sqlite3_bind_blob_go(sqlite3_stmt *stmt, int i, const char *zData, sqlite3_uint64 nData) { return sqlite3_bind_blob64(stmt, i, zData, nData, &sqlite3_free); } \ No newline at end of file diff --git a/sqlite3/result.c b/sqlite3/result.c index 6e79772..b59b26a 100644 --- a/sqlite3/result.c +++ b/sqlite3/result.c @@ -1,13 +1,14 @@ +#include #include #include "sqlite3.h" -void sqlite3_result_text_go(sqlite3_context* ctx, const char* zData, +void sqlite3_result_text_go(sqlite3_context *ctx, const char *zData, sqlite3_uint64 nData) { sqlite3_result_text64(ctx, zData, nData, &sqlite3_free, SQLITE_UTF8); } -void sqlite3_result_blob_go(sqlite3_context* ctx, const void* zData, +void sqlite3_result_blob_go(sqlite3_context *ctx, const void *zData, sqlite3_uint64 nData) { sqlite3_result_blob64(ctx, zData, nData, &sqlite3_free); } \ No newline at end of file diff --git a/vfs/memdb/api.go b/vfs/memdb/api.go index 8434889..eb12eba 100644 --- a/vfs/memdb/api.go +++ b/vfs/memdb/api.go @@ -43,7 +43,8 @@ func Create(name string, data []byte) { } // Convert data from WAL/2 to rollback journal. - if len(data) >= 20 && (data[18] == 2 && data[19] == 2 || + if len(data) >= 20 && (false || + data[18] == 2 && data[19] == 2 || data[18] == 3 && data[19] == 3) { data[18] = 1 data[19] = 1