Skip to content

Add pdo_sqlite tests for empty filename and in-memory uri #7662

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

Merged
merged 2 commits into from
Nov 24, 2021

Conversation

othercorey
Copy link
Contributor

Refs #76868.

It would seem that pdo_sqlite supports empty filename and URIs as well as in-memory URIs. This adds tests to support that.

https://bugs.php.net/bug.php?id=76868

@cmb69 I was following up on the empty filename commit you referenced in ext/sqlite3.

@cmb69
Copy link
Member

cmb69 commented Nov 17, 2021

Hmm, having these tests would mean we rely on that behavior, but we may want to change it. Having XFAIL tests would mean that we consider the current behavior a bug. Not sure what to do here.

@othercorey
Copy link
Contributor Author

You don't think this is working as expected?

// create with in-memory database
$db = new PDO('sqlite:file::memory:?cache=shared');

var_dump($db->exec('CREATE TABLE test1 (id INT);'));
Copy link
Member

Choose a reason for hiding this comment

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

Should this also open a second connection to check that it is actually shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could. I don't know if php is responsible for all the uri options working though. I was mainly testing the special case filenames.

Copy link
Member

Choose a reason for hiding this comment

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

Given that we don't directly pass the DSN to SQLite3, that additional check would make sense. It may also make sense to add an INI section with open_basedir=, because if open_basedir is set, file: URIs are not supported by PHP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FreeBSD fails for some reason. What is the recommended open_basedir setting and then target directory to use to trigger a fail on all platforms?

Copy link
Member

Choose a reason for hiding this comment

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

I think you could use open_basedir=. for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you could use open_basedir=. for that.

And write to what directory? If it doesn't restrict and creates a file, does it matter where it goes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found an example test to follow.

@cmb69
Copy link
Member

cmb69 commented Nov 18, 2021

You don't think this is working as expected?

Ah, should have checked more thoroughly. So https://bugs.php.net/bug.php?id=76868 would be merely a doc issue.

@nikic nikic merged commit 108bd44 into php:master Nov 24, 2021
@othercorey othercorey deleted the sqlite-tests branch November 24, 2021 14:04
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.

3 participants