Skip to content

Commit 54f92fc

Browse files
authored
ext/pdo_sqlite: simplifying sqlite3_exec usage. (#10910)
pdo_sqlite_error copy the error message via the php's allocator, while the one from sqlite3_exec is unused.
1 parent d854492 commit 54f92fc

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

ext/pdo_sqlite/sqlite_driver.c

+4-17
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,9 @@ static bool sqlite_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, pdo_stmt_t
203203
static zend_long sqlite_handle_doer(pdo_dbh_t *dbh, const zend_string *sql)
204204
{
205205
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
206-
char *errmsg = NULL;
207206

208-
if (sqlite3_exec(H->db, ZSTR_VAL(sql), NULL, NULL, &errmsg) != SQLITE_OK) {
207+
if (sqlite3_exec(H->db, ZSTR_VAL(sql), NULL, NULL, NULL) != SQLITE_OK) {
209208
pdo_sqlite_error(dbh);
210-
if (errmsg)
211-
sqlite3_free(errmsg);
212-
213209
return -1;
214210
} else {
215211
return sqlite3_changes(H->db);
@@ -241,12 +237,9 @@ static zend_string* sqlite_handle_quoter(pdo_dbh_t *dbh, const zend_string *unqu
241237
static bool sqlite_handle_begin(pdo_dbh_t *dbh)
242238
{
243239
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
244-
char *errmsg = NULL;
245240

246-
if (sqlite3_exec(H->db, "BEGIN", NULL, NULL, &errmsg) != SQLITE_OK) {
241+
if (sqlite3_exec(H->db, "BEGIN", NULL, NULL, NULL) != SQLITE_OK) {
247242
pdo_sqlite_error(dbh);
248-
if (errmsg)
249-
sqlite3_free(errmsg);
250243
return false;
251244
}
252245
return true;
@@ -255,12 +248,9 @@ static bool sqlite_handle_begin(pdo_dbh_t *dbh)
255248
static bool sqlite_handle_commit(pdo_dbh_t *dbh)
256249
{
257250
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
258-
char *errmsg = NULL;
259251

260-
if (sqlite3_exec(H->db, "COMMIT", NULL, NULL, &errmsg) != SQLITE_OK) {
252+
if (sqlite3_exec(H->db, "COMMIT", NULL, NULL, NULL) != SQLITE_OK) {
261253
pdo_sqlite_error(dbh);
262-
if (errmsg)
263-
sqlite3_free(errmsg);
264254
return false;
265255
}
266256
return true;
@@ -269,12 +259,9 @@ static bool sqlite_handle_commit(pdo_dbh_t *dbh)
269259
static bool sqlite_handle_rollback(pdo_dbh_t *dbh)
270260
{
271261
pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
272-
char *errmsg = NULL;
273262

274-
if (sqlite3_exec(H->db, "ROLLBACK", NULL, NULL, &errmsg) != SQLITE_OK) {
263+
if (sqlite3_exec(H->db, "ROLLBACK", NULL, NULL, NULL) != SQLITE_OK) {
275264
pdo_sqlite_error(dbh);
276-
if (errmsg)
277-
sqlite3_free(errmsg);
278265
return false;
279266
}
280267
return true;

0 commit comments

Comments
 (0)