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

Fix bug #78192 PDO SQLite reset columns on schema changed #4313

Closed
wants to merge 1 commit into from

Conversation

vincent4vx
Copy link
Contributor

Reset stmt->columns when column count changed on new execution of prepared statement.

Since PHP 7.2, sqlite3_prepare_v2 is used, which recompile statement on schema changed (and not raise schema changed exception). This behavior will change the result set columns, which can cause a segmentation fault when column count changed.

This fix will reset the loaded columns when the count changed to ensure that there were reloaded.
New columns are now returned on fetch.

Note: If a column name change, but without count change, the columns descriptions is not reloaded.

…has changed

Reset stmt->columns when column count changed on new execution of prepared statement
Copy link
Contributor

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Note: If a column name change, but without count change, the columns descriptions is not reloaded.

I think we should adress this as well (as of SQLite 3.25.0 RENAME COLUMN is supported), but this may affect ext/sqlite3, too, and since there appears to occur no segfault (only out-dated column names), this PR is good to be merged.

@cmb69
Copy link
Contributor

cmb69 commented Jun 28, 2019

Applied as 05c00a8. Also filed https://bugs.php.net/78227 regarding RENAME COLUMN.

@cmb69 cmb69 closed this Jun 28, 2019
php-pulls pushed a commit that referenced this pull request Dec 8, 2020
This has been fixed for PDO SQlite by GH-4313, however the same
issue also applied to PDO MySQL.

Move the column count setting function into the main PDO layer
(and export it) and then use it in both PDO SQLite and PDO MySQL.
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.

None yet

2 participants