ext/pdo_sqlite: add ATTR_SQL and ATTR_EXPANDED_SQL statement attributes#21456
Open
iliaal wants to merge 2 commits intophp:masterfrom
Open
ext/pdo_sqlite: add ATTR_SQL and ATTR_EXPANDED_SQL statement attributes#21456iliaal wants to merge 2 commits intophp:masterfrom
iliaal wants to merge 2 commits intophp:masterfrom
Conversation
…ment::setFetchMode When setFetchMode(PDO::FETCH_DEFAULT) is called, mode=0 (PDO_FETCH_USE_DEFAULT) gets stored as the statement's default fetch type. Later, do_fetch() tries to resolve PDO_FETCH_USE_DEFAULT by reading stmt->default_fetch_type, which is also 0 — circular reference that on 8.4 silently fell through to FETCH_BOTH and on master throws a ValueError. Resolve PDO_FETCH_USE_DEFAULT to the connection-level default early in pdo_stmt_setup_fetch_mode(), before flags extraction and the mode switch, so the rest of the function processes the actual fetch mode. Closes phpGH-20214
Add support for retrieving the SQL text of a prepared statement via
PDOStatement::getAttribute(), mirroring SQLite3Stmt::getSQL().
Pdo\Sqlite::ATTR_SQL - original SQL text (sqlite3_sql)
Pdo\Sqlite::ATTR_EXPANDED_SQL - SQL with bound parameters expanded
(sqlite3_expanded_sql)
Closes phpGH-21322
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #21322 -- adds support for retrieving the SQL text of a prepared PDO SQLite statement via
PDOStatement::getAttribute(), mirroringSQLite3Stmt::getSQL().Two new statement attributes on
Pdo\Sqlite:ATTR_SQL-- returns the original SQL text (sqlite3_sql())ATTR_EXPANDED_SQL-- returns SQL with bound parameters expanded (sqlite3_expanded_sql(), guarded by configure check)Changes
php_pdo_sqlite_int.h-- new enum valuesPDO_SQLITE_ATTR_SQL,PDO_SQLITE_ATTR_EXPANDED_SQLsqlite_statement.c-- handle new attributes inpdo_sqlite_stmt_get_attribute()config.m4/config.w32-- configure check forsqlite3_expanded_sqlpdo_sqlite.stub.php+pdo_sqlite_arginfo.h-- PHP-visible constantspdo_sqlite_getattr_sql.phpt, updatedpdo_sqlite_constants.phptFeature addition is fairly small, I don't think it needs an RFC.
Implements feature request #21322