Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userauth: don't register no-op auth functions and unify public API #1308

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

charlievieth
Copy link
Contributor

This commit changes Open to not register any of the auth functions when
userauth is disabled. It also unifies the public API of this library for
when userauth is enabled/disabled.

NOTE: This PR builds on and includes #1302

goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3
cpu: Apple M4 Pro
                       │   y1.txt    │               y3.txt                │
                       │   sec/op    │   sec/op     vs base                │
Suite/BenchmarkOpen-14   13.76µ ± 1%   12.37µ ± 1%  -10.11% (p=0.000 n=10)

                       │   y1.txt   │               y3.txt               │
                       │    B/op    │    B/op     vs base                │
Suite/BenchmarkOpen-14   712.0 ± 0%   111.0 ± 1%  -84.41% (p=0.000 n=10)

                       │   y1.txt    │               y3.txt               │
                       │  allocs/op  │ allocs/op   vs base                │
Suite/BenchmarkOpen-14   20.000 ± 0%   3.000 ± 0%  -85.00% (p=0.000 n=10)

This commit fixes a bug where the db connection would not always be
closed when an error occurred in Open. Additionally, it makes sure that
we always unregister any callbacks associated with the connection, which
previously did not always happen. This change consolidates the error
handling logic (previously, it had to be done for each return statement)
which should make it more difficult to introduce this type of bug in the
future.
This commit changes Open to not register any of the auth functions when
userauth is disabled. It also unifies the public API of this library for
when userauth is enabled/disabled.

goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3
cpu: Apple M4 Pro
                       │   y1.txt    │               y3.txt                │
                       │   sec/op    │   sec/op     vs base                │
Suite/BenchmarkOpen-14   13.76µ ± 1%   12.37µ ± 1%  -10.11% (p=0.000 n=10)

                       │   y1.txt   │               y3.txt               │
                       │    B/op    │    B/op     vs base                │
Suite/BenchmarkOpen-14   712.0 ± 0%   111.0 ± 1%  -84.41% (p=0.000 n=10)

                       │   y1.txt    │               y3.txt               │
                       │  allocs/op  │ allocs/op   vs base                │
Suite/BenchmarkOpen-14   20.000 ± 0%   3.000 ± 0%  -85.00% (p=0.000 n=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant