Skip to content
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
31 changes: 5 additions & 26 deletions ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,29 +391,6 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_
}
/* }}} */

static bool pdo_stmt_do_next_rowset(pdo_stmt_t *stmt);

static void pdo_stmt_invalidate_result(pdo_stmt_t *stmt)
{
if (stmt->methods->cursor_closer) {
stmt->methods->cursor_closer(stmt);
} else {
do {
while (stmt->methods->fetcher(stmt, PDO_FETCH_ORI_NEXT, 0))
;
if (!stmt->methods->next_rowset) {
break;
}

if (!pdo_stmt_do_next_rowset(stmt)) {
break;
}
} while (1);
}

stmt->executed = 0;
}

/* {{{ Execute a prepared statement, optionally binding parameters */
PHP_METHOD(PDOStatement, execute)
{
Expand All @@ -430,9 +407,10 @@ PHP_METHOD(PDOStatement, execute)
RETURN_THROWS();
}

if (stmt->executed) {
pdo_stmt_invalidate_result(stmt);
if (stmt->executed && stmt->methods->cursor_closer) {
stmt->methods->cursor_closer(stmt);
}
stmt->execute_incomplete = 1;
PDO_STMT_CLEAR_ERR();

if (input_params) {
Expand Down Expand Up @@ -499,6 +477,7 @@ PHP_METHOD(PDOStatement, execute)
RETURN_FALSE;
}
if (stmt->methods->executer(stmt)) {
stmt->execute_incomplete = 0;
if (!stmt->executed) {
/* this is the first execute */

Expand Down Expand Up @@ -605,7 +584,7 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, enum pdo

static bool do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* {{{ */
{
if (!stmt->executed) {
if (!stmt->executed || stmt->execute_incomplete) {
return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion ext/pdo/php_pdo_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,9 @@ struct _pdo_stmt_t {
* emulate prepare and bind on its behalf */
unsigned supports_placeholders:2;
unsigned in_param_event:1;
unsigned execute_incomplete:1;

unsigned _reserved:28;
unsigned _reserved:27;

/* the number of columns in the result set; not valid until after
* the statement has been executed at least once. In some cases, might
Expand Down
Loading