From d633691b5bbfb109f0e47c19af43f341fdc1e0a3 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Fri, 10 Nov 2017 15:04:07 -0800 Subject: [PATCH] Raised the initial buffer size and modified tests as per review --- source/shared/core_results.cpp | 2 +- .../pdo_sqlsrv/pdo_574_next_rowset.phpt | 34 ++++++++++++++----- .../sqlsrv/sqlsrv_574_next_result.phpt | 34 ++++++++++++++----- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/source/shared/core_results.cpp b/source/shared/core_results.cpp index a1ec6039..70b4a59e 100644 --- a/source/shared/core_results.cpp +++ b/source/shared/core_results.cpp @@ -45,7 +45,7 @@ namespace { // *** internal constants *** -const int INITIAL_FIELD_STRING_LEN = 1024; // base allocation size when retrieving a string field +const int INITIAL_FIELD_STRING_LEN = 8000; // base allocation size when retrieving a string field // *** internal functions *** diff --git a/test/functional/pdo_sqlsrv/pdo_574_next_rowset.phpt b/test/functional/pdo_sqlsrv/pdo_574_next_rowset.phpt index 896a77ab..d4c0e811 100644 --- a/test/functional/pdo_sqlsrv/pdo_574_next_rowset.phpt +++ b/test/functional/pdo_sqlsrv/pdo_574_next_rowset.phpt @@ -24,12 +24,12 @@ try { createTable($conn, $tableName1, $columns); // insert one row to each table - $phrase = str_repeat('This is a test ', 250); + $phrase = str_repeat('This is a test ', 25000); $stmt = insertRow($conn, $tableName, array('col1' => $phrase)); unset($stmt); - $phrase = str_repeat('This is indeed very long ', 300); - $stmt = insertRow($conn, $tableName1, array('col1' => $phrase)); + $phrase1 = str_repeat('This is indeed very long ', 30000); + $stmt = insertRow($conn, $tableName1, array('col1' => $phrase1)); unset($stmt); // run queries in a batch @@ -39,7 +39,11 @@ try { // fetch from $tableName $row = $stmt->fetch(PDO::FETCH_NUM); if ($row) { - echo(substr($row[0], 0, 15)) . PHP_EOL; + if ($row[0] === $phrase) { + echo(substr($row[0], 0, 15)) . PHP_EOL; + } else { + echo "Incorrect value substr($row[0], 0, 1000)...!" . PHP_EOL; + } } // fetch from cd_info @@ -49,7 +53,7 @@ try { $row = $stmt->fetch(PDO::FETCH_NUM); if ($row) { - echo(substr($row[0], 0, 15)) . PHP_EOL; + echo $row[0] . PHP_EOL; } // fetch from $tableName1 @@ -59,7 +63,11 @@ try { $row = $stmt->fetch(PDO::FETCH_NUM); if ($row) { - echo(substr($row[0], 0, 25)) . PHP_EOL; + if ($row[0] === $phrase1) { + echo(substr($row[0], 0, 25)) . PHP_EOL; + } else { + echo "Incorrect value substr($row[0], 0, 1000)...!" . PHP_EOL; + } } // should be no more next results, first returns false second throws an exception @@ -90,7 +98,7 @@ try { // fetch from cd_info $row = $stmt->fetch(PDO::FETCH_NUM); if ($row) { - echo(substr($row[0], 0, 15)) . PHP_EOL; + echo $row[0] . PHP_EOL; } // re-execute the statement, should return to the first query in the batch @@ -99,7 +107,11 @@ try { // fetch from $tableName1 $row = $stmt->fetch(PDO::FETCH_NUM); if ($row) { - echo(substr($row[0], 0, 25)) . PHP_EOL; + if ($row[0] === $phrase1) { + echo(substr($row[0], 0, 25)) . PHP_EOL; + } else { + echo "Incorrect value substr($row[0], 0, 1000)...!" . PHP_EOL; + } } unset($stmt); @@ -109,7 +121,11 @@ try { // fetch from $tableName $row = $stmt->fetch(PDO::FETCH_NUM); if ($row) { - echo(substr($row[0], 0, 15)) . PHP_EOL; + if ($row[0] === $phrase) { + echo(substr($row[0], 0, 15)) . PHP_EOL; + } else { + echo "Incorrect value substr($row[0], 0, 1000)...!" . PHP_EOL; + } } // should be no more next results, first returns false second throws an exception diff --git a/test/functional/sqlsrv/sqlsrv_574_next_result.phpt b/test/functional/sqlsrv/sqlsrv_574_next_result.phpt index 99816369..c21f7178 100644 --- a/test/functional/sqlsrv/sqlsrv_574_next_result.phpt +++ b/test/functional/sqlsrv/sqlsrv_574_next_result.phpt @@ -30,7 +30,7 @@ if (!$stmt) { // insert one row to each table $sql = "insert into $tableName (col1) VALUES (?)"; -$phrase = str_repeat('This is a test ', 250); +$phrase = str_repeat('This is a test ', 25000); $stmt = sqlsrv_prepare($conn, $sql, array($phrase)); if ($stmt) { @@ -40,9 +40,9 @@ if ($stmt) { } } -$phrase = str_repeat('This is indeed very long ', 300); +$phrase1 = str_repeat('This is indeed very long ', 30000); $sql = "insert into $tableName1 (col1) VALUES (?)"; -$stmt = sqlsrv_prepare($conn, $sql, array($phrase)); +$stmt = sqlsrv_prepare($conn, $sql, array($phrase1)); if ($stmt) { $r = sqlsrv_execute($stmt); if (!$r) { @@ -63,7 +63,11 @@ if ($stmt) { $row = sqlsrv_fetch($stmt); if ($row) { $fld = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR)); - echo(substr($fld, 0, 15)) . PHP_EOL; + if ($fld === $phrase) { + echo(substr($fld, 0, 15)) . PHP_EOL; + } else { + echo "Incorrect value substr($fld, 0, 1000)...!" . PHP_EOL; + } } // fetch from cd_info @@ -74,7 +78,7 @@ var_dump($next); $row = sqlsrv_fetch($stmt); if ($row) { $fld = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR)); - echo(substr($fld, 0, 15)) . PHP_EOL; + echo $fld . PHP_EOL; } // fetch from $tableName1 @@ -85,7 +89,11 @@ var_dump($next); $row = sqlsrv_fetch($stmt); if ($row) { $fld = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR)); - echo(substr($fld, 0, 25)) . PHP_EOL; + if ($fld === $phrase1) { + echo(substr($fld, 0, 25)) . PHP_EOL; + } else { + echo "Incorrect value substr($fld, 0, 1000)...!" . PHP_EOL; + } } // should be no more next results, first returns NULL second returns false @@ -119,7 +127,7 @@ sqlsrv_next_result($stmt); $row = sqlsrv_fetch($stmt); if ($row) { $fld = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR)); - echo(substr($fld, 0, 15)) . PHP_EOL; + echo $fld . PHP_EOL; } // re-execute the statement, should return to the first query in the batch @@ -132,7 +140,11 @@ if (!$r) { $row = sqlsrv_fetch($stmt); if ($row) { $fld = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR)); - echo(substr($fld, 0, 25)) . PHP_EOL; + if ($fld === $phrase1) { + echo(substr($fld, 0, 25)) . PHP_EOL; + } else { + echo "Incorrect value substr($fld, 0, 1000)...!" . PHP_EOL; + } } sqlsrv_free_stmt($stmt); @@ -149,7 +161,11 @@ if ($stmt) { $row = sqlsrv_fetch($stmt); if ($row) { $fld = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR)); - echo(substr($fld, 0, 15)) . PHP_EOL; + if ($fld === $phrase) { + echo(substr($fld, 0, 15)) . PHP_EOL; + } else { + echo "Incorrect value substr($fld, 0, 1000)...!" . PHP_EOL; + } } // should be no more next results, first returns NULL second returns false