Skip to content

Skip profiling of sqlite3_step #12130

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion ext/pdo_sqlite/sqlite_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "php_pdo_sqlite.h"
#include "php_pdo_sqlite_int.h"

#ifdef HAVE_VALGRIND
# include "valgrind/callgrind.h"
#endif

static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt)
{
Expand All @@ -48,7 +51,14 @@ static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt)
}

S->done = 0;
switch (sqlite3_step(S->stmt)) {
#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
int result = sqlite3_step(S->stmt);
#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
switch (result) {
case SQLITE_ROW:
S->pre_fetched = 1;
php_pdo_stmt_set_column_count(stmt, sqlite3_data_count(S->stmt));
Expand Down Expand Up @@ -214,7 +224,13 @@ static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt,
if (S->done) {
return 0;
}
#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
i = sqlite3_step(S->stmt);
#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
switch (i) {
case SQLITE_ROW:
return 1;
Expand Down
29 changes: 29 additions & 0 deletions ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include "SAPI.h"
#include "sqlite3_arginfo.h"

#ifdef HAVE_VALGRIND
# include "valgrind/callgrind.h"
#endif

ZEND_DECLARE_MODULE_GLOBALS(sqlite3)

static PHP_GINIT_FUNCTION(sqlite3);
Expand Down Expand Up @@ -595,7 +599,14 @@ PHP_METHOD(SQLite3, query)
result->column_count = -1;
ZVAL_OBJ(&result->stmt_obj_zval, Z_OBJ(stmt));


#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
return_code = sqlite3_step(result->stmt_obj->stmt);
#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif

switch (return_code) {
case SQLITE_ROW: /* Valid Row */
Expand Down Expand Up @@ -697,7 +708,13 @@ PHP_METHOD(SQLite3, querySingle)
RETURN_FALSE;
}

#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
return_code = sqlite3_step(stmt);
#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif

switch (return_code) {
case SQLITE_ROW: /* Valid Row */
Expand Down Expand Up @@ -1796,7 +1813,13 @@ PHP_METHOD(SQLite3Stmt, execute)
RETURN_FALSE;
}

#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
return_code = sqlite3_step(stmt_obj->stmt);
#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif

switch (return_code) {
case SQLITE_ROW: /* Valid Row */
Expand Down Expand Up @@ -1953,7 +1976,13 @@ PHP_METHOD(SQLite3Result, fetchArray)

SQLITE3_CHECK_INITIALIZED(result_obj->db_obj, result_obj->stmt_obj->initialised, SQLite3Result)

#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
ret = sqlite3_step(result_obj->stmt_obj->stmt);
#ifdef HAVE_VALGRIND
CALLGRIND_TOGGLE_COLLECT;
#endif
switch (ret) {
case SQLITE_ROW:
/* If there was no return value then just skip fetching */
Expand Down