diff --git a/driver/driver.go b/driver/driver.go index e7863b1..3ded80a 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -231,6 +231,7 @@ func (c *conn) Raw() *sqlite3.Conn { // Deprecated: use BeginTx instead. func (c *conn) Begin() (driver.Tx, error) { + // notest return c.BeginTx(context.Background(), driver.TxOptions{}) } @@ -287,6 +288,7 @@ func (c *conn) Rollback() error { } func (c *conn) Prepare(query string) (driver.Stmt, error) { + // notest return c.PrepareContext(context.Background(), query) } @@ -363,11 +365,13 @@ func (s *stmt) NumInput() int { // Deprecated: use ExecContext instead. func (s *stmt) Exec(args []driver.Value) (driver.Result, error) { + // notest return s.ExecContext(context.Background(), namedValues(args)) } // Deprecated: use QueryContext instead. func (s *stmt) Query(args []driver.Value) (driver.Rows, error) { + // notest return s.QueryContext(context.Background(), namedValues(args)) } diff --git a/ext/bloom/bloom.go b/ext/bloom/bloom.go index b1285b5..cda142d 100644 --- a/ext/bloom/bloom.go +++ b/ext/bloom/bloom.go @@ -328,6 +328,7 @@ func (c *cursor) EOF() bool { } func (c *cursor) RowID() (int64, error) { + // notest // WITHOUT ROWID return 0, nil } diff --git a/ext/pivot/pivot_test.go b/ext/pivot/pivot_test.go index c8ccd6a..41b8389 100644 --- a/ext/pivot/pivot_test.go +++ b/ext/pivot/pivot_test.go @@ -144,6 +144,11 @@ func TestRegister(t *testing.T) { t.Errorf("got %d, want 3", got) } } + + err = db.Exec(`ALTER TABLE v_x RENAME TO v_y`) + if err != nil { + t.Fatal(err) + } } func TestRegister_errors(t *testing.T) { diff --git a/ext/zorder/zorder.go b/ext/zorder/zorder.go index 9ba6e47..37f8e71 100644 --- a/ext/zorder/zorder.go +++ b/ext/zorder/zorder.go @@ -20,17 +20,17 @@ func Register(db *sqlite3.Conn) error { func zorder(ctx sqlite3.Context, arg ...sqlite3.Value) { var x [63]int64 - for i := range arg { - x[i] = arg[i].Int64() - } if len(arg) > len(x) { ctx.ResultError(util.ErrorString("zorder: too many parameters")) return } + for i := range arg { + x[i] = arg[i].Int64() + } var z int64 if len(arg) > 0 { - for i := 0; i < 63; i++ { + for i := range x { j := i % len(arg) z |= (x[j] & 1) << i x[j] >>= 1 diff --git a/ext/zorder/zorder_test.go b/ext/zorder/zorder_test.go index fd2632a..484ca4d 100644 --- a/ext/zorder/zorder_test.go +++ b/ext/zorder/zorder_test.go @@ -1,6 +1,8 @@ package zorder_test import ( + "strconv" + "strings" "testing" "github.com/ncruces/go-sqlite3/driver" @@ -94,4 +96,16 @@ func TestRegister_error(t *testing.T) { if err == nil { t.Error("want error") } + + var buf strings.Builder + buf.WriteString("SELECT zorder(0") + for i := 1; i < 80; i++ { + buf.WriteByte(',') + buf.WriteString(strconv.Itoa(0)) + } + buf.WriteByte(')') + err = db.QueryRow(buf.String()).Scan(&got) + if err == nil { + t.Error("want error") + } } diff --git a/tests/conn_test.go b/tests/conn_test.go index 2525bcc..aba68c1 100644 --- a/tests/conn_test.go +++ b/tests/conn_test.go @@ -172,6 +172,11 @@ func TestConn_SetInterrupt(t *testing.T) { if err != nil { t.Fatal(err) } + + db.SetInterrupt(ctx) + if got := db.GetInterrupt(); got != ctx { + t.Errorf("got %v, want %v", got, ctx) + } } func TestConn_Prepare_empty(t *testing.T) { @@ -372,13 +377,25 @@ func TestConn_SetAuthorizer(t *testing.T) { defer db.Close() err = db.SetAuthorizer(func(action sqlite3.AuthorizerActionCode, name3rd, name4th, schema, nameInner string) sqlite3.AuthorizerReturnCode { + if action != sqlite3.AUTH_PRAGMA { + t.Errorf("got %v, want PRAGMA", action) + } + if name3rd != "busy_timeout" { + t.Errorf("got %q, want busy_timeout", name3rd) + } + if name4th != "5000" { + t.Errorf("got %q, want 5000", name4th) + } + if schema != "main" { + t.Errorf("got %q, want main", schema) + } return sqlite3.AUTH_DENY }) if err != nil { t.Fatal(err) } - err = db.Exec(`SELECT * FROM sqlite_schema`) + err = db.Exec(`PRAGMA main.busy_timeout=5000`) if !errors.Is(err, sqlite3.AUTH) { t.Errorf("got %v, want sqlite3.AUTH", err) }