diff --git a/NEWS b/NEWS index f8e5aa877345..33185ccd3d09 100644 --- a/NEWS +++ b/NEWS @@ -200,6 +200,11 @@ PHP NEWS . Fixed a crash when executing a prepared statement again after a failed execute() with libmysqlclient. (Ilia Alshanetsky) +- PDO_ODBC: + . Fixed bug GH-25390 (fetching a long text / ntext value allocates the + declared column size when the driver returns SQL_NO_TOTAL). (licvido, + chep6915) + - PDO_PGSQL: . Fixed bug GH-25838 (use-after-free when a lazy statement follows a failed query). (Yun Dou) diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 324fdfc31487..3c613ed61a0d 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -778,9 +778,7 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo * changed from 256 byte to LONG_COLUMN_BUFFER_SIZE. */ ssize_t to_fetch_len; - if (orig_fetched_len == SQL_NO_TOTAL && C->datalen > (LONG_COLUMN_BUFFER_SIZE - 1)) { - to_fetch_len = C->datalen; - } else if (orig_fetched_len > 0) { + if (orig_fetched_len > 0) { /* implicitly not SQL_NO_TOTAL, should be OK */ to_fetch_len = orig_fetched_len; } else { diff --git a/ext/pdo_odbc/tests/gh25390.phpt b/ext/pdo_odbc/tests/gh25390.phpt new file mode 100644 index 000000000000..f2bfd4c2d7c5 --- /dev/null +++ b/ext/pdo_odbc/tests/gh25390.phpt @@ -0,0 +1,33 @@ +--TEST-- +GH-25390 (fetching a long text / ntext value allocates the declared column size when the driver returns SQL_NO_TOTAL) +--EXTENSIONS-- +pdo_odbc +--SKIPIF-- + +--INI-- +memory_limit=256M +--FILE-- +query("SELECT CAST(REPLICATE(CAST('A' AS varchar(max)), $n) AS text) AS v")->fetch(PDO::FETCH_ASSOC); + var_dump(strlen($row['v'])); + $row = $db->query("SELECT CAST(REPLICATE(CAST(N'A' AS nvarchar(max)), $n) AS ntext) AS v")->fetch(PDO::FETCH_ASSOC); + var_dump(strlen($row['v'])); +} +?> +--EXPECT-- +int(4073) +int(4073) +int(300000) +int(300000)