From 7b8b2e50f6efacb52aed4fa500a16638c56c8ca4 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Sun, 22 Jan 2017 07:26:07 -0800 Subject: [PATCH] Switch to the v2 version of these functions. The sqlite3 docs suggest always using prepare_v2 and the close_v2 could potentially help with an fd leak we have been seeing --- NEWS | 3 +++ UPGRADING | 4 ++++ ext/pdo_sqlite/sqlite_driver.c | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index cb835f4311..45d6df5be2 100644 --- a/NEWS +++ b/NEWS @@ -99,6 +99,9 @@ PHP NEWS . Fixed bug #73959 (lastInsertId fails to throw an exception for wrong sequence name). (andrewnester) +- PDO_Sqlite + . Switch to sqlite3_prepare_v2() and sqlite3_close_v2() functions (rasmus) + - posix: . Fixed bug #71219 (configure script incorrectly checks for ttyname_r). (atoh) diff --git a/UPGRADING b/UPGRADING index 6b429dae79..af739b81a4 100644 --- a/UPGRADING +++ b/UPGRADING @@ -189,6 +189,10 @@ PHP 7.2 UPGRADE NOTES . mb_convert_encoding() accepts array parameter. Only value encodings are converted recursively. +- pdo_sqlite + . Use sqlite3_prepare_v2() and sqlite3_close_v2() functions instead of their + legacy counterparts. + ======================================== 10. New Global Constants ======================================== diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index 80b52d550b..c5fd54cfb4 100644 --- a/ext/pdo_sqlite/sqlite_driver.c +++ b/ext/pdo_sqlite/sqlite_driver.c @@ -161,7 +161,7 @@ static int sqlite_handle_closer(pdo_dbh_t *dbh) /* {{{ */ pdo_sqlite_cleanup_callbacks(H); if (H->db) { - sqlite3_close(H->db); + sqlite3_close_v2(H->db); H->db = NULL; } if (einfo->errmsg) { @@ -193,7 +193,7 @@ static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, size_t sql_le return 0; } - i = sqlite3_prepare(H->db, sql, sql_len, &S->stmt, &tail); + i = sqlite3_prepare_v2(H->db, sql, sql_len, &S->stmt, &tail); if (i == SQLITE_OK) { return 1; } -- 2.40.0