mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
PDO MySQL: Fix nextRowset() on libmysqlclient with native PS
The logic after next_result should match the one after execute. This was the case for mysqlnd but not libmysqlclient, which used the non-PS logic.
This commit is contained in:
parent
81f012a164
commit
7a89157f8c
2 changed files with 79 additions and 93 deletions
|
@ -158,11 +158,11 @@ static int pdo_mysql_fill_stmt_from_result(pdo_stmt_t *stmt) /* {{{ */
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
#ifdef PDO_USE_MYSQLND
|
|
||||||
static bool pdo_mysql_stmt_after_execute_prepared(pdo_stmt_t *stmt) {
|
static bool pdo_mysql_stmt_after_execute_prepared(pdo_stmt_t *stmt) {
|
||||||
pdo_mysql_stmt *S = stmt->driver_data;
|
pdo_mysql_stmt *S = stmt->driver_data;
|
||||||
pdo_mysql_db_handle *H = S->H;
|
pdo_mysql_db_handle *H = S->H;
|
||||||
|
|
||||||
|
#ifdef PDO_USE_MYSQLND
|
||||||
/* For SHOW/DESCRIBE and others the column/field count is not available before execute. */
|
/* For SHOW/DESCRIBE and others the column/field count is not available before execute. */
|
||||||
php_pdo_stmt_set_column_count(stmt, mysql_stmt_field_count(S->stmt));
|
php_pdo_stmt_set_column_count(stmt, mysql_stmt_field_count(S->stmt));
|
||||||
for (int i = 0; i < stmt->column_count; i++) {
|
for (int i = 0; i < stmt->column_count; i++) {
|
||||||
|
@ -180,36 +180,7 @@ static bool pdo_mysql_stmt_after_execute_prepared(pdo_stmt_t *stmt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
pdo_mysql_stmt_set_row_count(stmt);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PDO_USE_MYSQLND
|
|
||||||
static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */
|
|
||||||
{
|
|
||||||
pdo_mysql_stmt *S = stmt->driver_data;
|
|
||||||
pdo_mysql_db_handle *H = S->H;
|
|
||||||
|
|
||||||
PDO_DBG_ENTER("pdo_mysql_stmt_execute_prepared_libmysql");
|
|
||||||
|
|
||||||
/* (re)bind the parameters */
|
|
||||||
if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) {
|
|
||||||
if (S->params) {
|
|
||||||
memset(S->params, 0, S->num_params * sizeof(MYSQL_BIND));
|
|
||||||
}
|
|
||||||
pdo_mysql_error_stmt(stmt);
|
|
||||||
if (mysql_stmt_errno(S->stmt) == 2057) {
|
|
||||||
/* CR_NEW_STMT_METADATA makes the statement unusable */
|
|
||||||
S->stmt = NULL;
|
|
||||||
}
|
|
||||||
PDO_DBG_RETURN(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!S->result) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* figure out the result set format, if any */
|
/* figure out the result set format, if any */
|
||||||
S->result = mysql_stmt_result_metadata(S->stmt);
|
S->result = mysql_stmt_result_metadata(S->stmt);
|
||||||
if (S->result) {
|
if (S->result) {
|
||||||
|
@ -222,7 +193,7 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */
|
||||||
S->out_length = ecalloc(stmt->column_count, sizeof(zend_ulong));
|
S->out_length = ecalloc(stmt->column_count, sizeof(zend_ulong));
|
||||||
|
|
||||||
/* summon memory to hold the row */
|
/* summon memory to hold the row */
|
||||||
for (i = 0; i < stmt->column_count; i++) {
|
for (int i = 0; i < stmt->column_count; i++) {
|
||||||
if (calc_max_length && S->fields[i].type == FIELD_TYPE_BLOB) {
|
if (calc_max_length && S->fields[i].type == FIELD_TYPE_BLOB) {
|
||||||
my_bool on = 1;
|
my_bool on = 1;
|
||||||
mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on);
|
mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on);
|
||||||
|
@ -283,10 +254,33 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
pdo_mysql_stmt_set_row_count(stmt);
|
pdo_mysql_stmt_set_row_count(stmt);
|
||||||
PDO_DBG_RETURN(1);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef PDO_USE_MYSQLND
|
||||||
|
static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */
|
||||||
|
{
|
||||||
|
pdo_mysql_stmt *S = stmt->driver_data;
|
||||||
|
|
||||||
|
PDO_DBG_ENTER("pdo_mysql_stmt_execute_prepared_libmysql");
|
||||||
|
|
||||||
|
/* (re)bind the parameters */
|
||||||
|
if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) {
|
||||||
|
if (S->params) {
|
||||||
|
memset(S->params, 0, S->num_params * sizeof(MYSQL_BIND));
|
||||||
|
}
|
||||||
|
pdo_mysql_error_stmt(stmt);
|
||||||
|
if (mysql_stmt_errno(S->stmt) == 2057) {
|
||||||
|
/* CR_NEW_STMT_METADATA makes the statement unusable */
|
||||||
|
S->stmt = NULL;
|
||||||
|
}
|
||||||
|
PDO_DBG_RETURN(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt));
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
#endif
|
#endif
|
||||||
|
@ -349,20 +343,15 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */
|
||||||
S->done = 1;
|
S->done = 1;
|
||||||
PDO_DBG_RETURN(0);
|
PDO_DBG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt));
|
||||||
} else {
|
} else {
|
||||||
if (mysql_next_result(H->server)) {
|
if (mysql_next_result(H->server)) {
|
||||||
pdo_mysql_error_stmt(stmt);
|
pdo_mysql_error_stmt(stmt);
|
||||||
S->done = 1;
|
S->done = 1;
|
||||||
PDO_DBG_RETURN(0);
|
PDO_DBG_RETURN(0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PDO_USE_MYSQLND
|
|
||||||
if (S->stmt) {
|
|
||||||
PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt));
|
PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,6 @@ $version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||||
if ($version < 50000)
|
if ($version < 50000)
|
||||||
die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
|
die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
|
||||||
$matches[1], $matches[2], $matches[3], $version));
|
$matches[1], $matches[2], $matches[3], $version));
|
||||||
|
|
||||||
if (!MySQLPDOTest::isPDOMySQLnd())
|
|
||||||
die("skip This will not work with libmysql");
|
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue