Skip to content

Problem with memory SQLite and multiple connections #124

@element-of-surprise

Description

@element-of-surprise

Wanted to confirm a problem and then I can create a PR with a fix if your interested in taking changes for bugs.

Was having a problem where if I created a pool with more than one connection on a memory SQLite I couldn't see changes in any other connection, including table creation.

I assumed I was doing something terribly wrong. But apparently there is this error:

https://github.com/zombiezen/go-sqlite/blob/v1.4.2/sqlitex/pool.go#L72C1-L74C3

Unfortunately I'm not tripping that error when I do:

pool, err := sqlitex.NewPool(path, sqlitex.PoolOptions{Flags: flags, PoolSize: 1})

My path is not ":memory:" and there doesn't seem to be a requirement that if the flag sqlite.OpenMemory is used that the uri must be ":memory:", so you can bypass that warning.

There seems two ways to fix this:

  • Enforce uri == ":memory:" if flag sqlite.OpenMemory is set, then do the check listed above
  • Simply do the same check but have a uri == memory || sqlite.OpenMemory is set.

I'm happy to generate a PR that does whichever one your prefer, if you are so inclined.

And thank you for such a great set of packages. Really are just great.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions