Skip to content

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Oct 6, 2025

No description provided.

@nielsdos
Copy link
Member Author

nielsdos commented Oct 6, 2025

Fails for some reason, marking as draft until I figured it out.

@nielsdos nielsdos marked this pull request as draft October 6, 2025 16:43
return estrdup(filename);
}
if (*filename && strcmp(filename, ":memory:")) {
if (*filename && strncmp(filename, ":memory:", sizeof(":memory:")-1) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this 100% safe and wouldn't be something like :memory:/path processed like regular filepath?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this is not only theoretical, but also the real reason why the CI is failing - a file (instead of in-memory DB) is created.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The official condition is in https://github.com/sqlite/sqlite/blob/version-3.50.4/src/btree.c#L2552.

I even wonder what is :memory:?cache=shared, I did not find any testcase for it in Sqlite codebase.

Copy link

@AnrDaemon AnrDaemon Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "cache" connection parameter lets you specify the "shared key" to connect to in-memory database created in a different process.
Ref: https://www.sqlite.org/inmemorydb.html#sharedmemdb

The value could be anything, on production we're using UUID generated at deploy time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLite: PDOException: open_basedir prohibits opening :memory:?cache=shared
3 participants