From d9b6e054557449319308f620fdb46cc0eba6e1a4 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Fri, 25 Jan 2019 15:53:58 -0800 Subject: [PATCH] Added new tests for setting client buffer size related to issue 228 (#920) --- ...28_setAttribute_clientbuffermaxkbsize.phpt | 32 +++-- ...etConnAttribute_clientbuffermaxkbsize.phpt | 94 +++++++++++++++ .../srv_228_sqlsrv_clientbuffermaxkbsize.phpt | 45 ++++++-- ...8_sqlsrv_clientbuffermaxkbsize_option.phpt | 109 ++++++++++++++++++ 4 files changed, 260 insertions(+), 20 deletions(-) create mode 100644 test/functional/pdo_sqlsrv/pdo_228_setConnAttribute_clientbuffermaxkbsize.phpt create mode 100644 test/functional/sqlsrv/srv_228_sqlsrv_clientbuffermaxkbsize_option.phpt diff --git a/test/functional/pdo_sqlsrv/pdo_228_setAttribute_clientbuffermaxkbsize.phpt b/test/functional/pdo_sqlsrv/pdo_228_setAttribute_clientbuffermaxkbsize.phpt index 0e94b105..fd2517d8 100644 --- a/test/functional/pdo_sqlsrv/pdo_228_setAttribute_clientbuffermaxkbsize.phpt +++ b/test/functional/pdo_sqlsrv/pdo_228_setAttribute_clientbuffermaxkbsize.phpt @@ -1,5 +1,7 @@ --TEST-- -sqlsrv_has_rows() using a forward and scrollable cursor +GitHub issue #228 - how max client buffer size affects the fetching of data +--DESCRIPTION-- +A pdo_sqlsrv variation of the example in GitHub issue 228, using PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE the statement attribute. --SKIPIF-- --FILE-- @@ -21,28 +23,38 @@ try { insertRow($conn, $tableName2, array("c1_int" => 990021574, "c2_varchar" => ">vh~Ö.bÐ*äß/ÄAabýZâOüzr£ðAß+|~|OU¢a|U<ßrv.uCB.ÐÜh_î+ãå@üðöã,U+ßvuU:/ý_Öãî/ð|bB|_Zbua©r++BA¢z£.üî¢öåäözÜ¢ßb:aöCrÄ~ýZ¢uªÐö.hhßð*zÜÜß*ãüåýãÄ+åýüüaߢÃÐBî@~AZöÃOßC@äoÃuCÜ,ÐÄa:îäÄÖý:h*ouªuåvUz_ArßAªãaãvÐåAUüAB:¢Äz|öub<üZvößüå:ãÄ@r/ZAÄðÄÄvzîv~C/£|ýýbüÖ~£|Öå<Üa~/v@åAz©¢£U_ßhbaÃß,zz<ã¢|<ä©>öAuövÖ>abu,zå,+ß/ü/ª_bbB:ÃC~£ü/O©O©ªAª_,|a¢~ýý/b>ßC@/böîöh>~£ð+Bßr©ÄÐÖßã:bA@:>B:UAbããîÜ~uÜ£îCöÖ£©_ÜßzÐ+ÖýZb,A:<z.ãîÄzC@©*ä|ã._ßZOäb¢Cßovå+uv.£B~~b£ª|ÖÄîßö>©Ãbb|©©ðA£åO~âãüîuvÄÜýUzîOÖ/oOßO*>ªßzêÖÐböÄåbîðîÐa~©ßîÄßУ<î>åBã_ý*ah¢rOĪ,ßo¢¢a|BÖäzU£.B£@Ü,ßAÃ>,ðßß+ßÜ©|Ðr©bCðТüãz>AßðåÃ>bÄåÄ|Z~äÃ/Cb*£bð_/Ða@~AÜãO+ý*CîîÃzÄöÃa©+@vuz>î>©.Cv>hÃý>©Bä,ö~@~@r,AðCu@Ü,@U*ÐvöÃêuã.Öa*uZªoZ/ðÖ©ßv_<ÖvåÜÐÜOÐoðßðÃUýZÐB:+ÄÃã£")); $size = 2; - $stmt = $conn->prepare("SELECT * FROM $tableName1", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size)); - $attr = $stmt->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE')); + $stmt = $conn->prepare("SELECT * FROM $tableName1", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size)); + $attr = $stmt->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE')); echo("Client Buffer Size in KB: $attr\n"); - $stmt->execute(); + $stmt->execute(); $numRows = 0; while ($result = $stmt->fetch()) { $numRows++; } echo ("Number of rows: $numRows\n"); - $size = 3; - $stmt = $conn->prepare("SELECT * FROM $tableName2", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size)); - $attr = $stmt->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE')); + $size = 3; + $stmt = $conn->prepare("SELECT * FROM $tableName2", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size)); + $attr = $stmt->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE')); echo("Client Buffer Size in KB: $attr\n"); - $stmt->execute(); + $stmt->execute(); $numRows = 0; while ($result = $stmt->fetch()) { $numRows++; } - echo ("Number of rows: $numRows\n"); + $size = 1; + $stmt = $conn->prepare("SELECT * FROM $tableName2", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size)); + $attr = $stmt->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE')); + echo("Client Buffer Size in KB: $attr\n"); + try { + $stmt->execute(); + echo "Expect this to fail!!\n"; + } catch (PDOException $e) { + var_dump($e->getMessage()); + } + dropTable($conn, $tableName1); dropTable($conn, $tableName2); unset($stmt); @@ -58,4 +70,6 @@ Client Buffer Size in KB: 2 Number of rows: 1 Client Buffer Size in KB: 3 Number of rows: 1 +Client Buffer Size in KB: 1 +string(65) "SQLSTATE[IMSSP]: Memory limit of 1 KB exceeded for buffered query" Done diff --git a/test/functional/pdo_sqlsrv/pdo_228_setConnAttribute_clientbuffermaxkbsize.phpt b/test/functional/pdo_sqlsrv/pdo_228_setConnAttribute_clientbuffermaxkbsize.phpt new file mode 100644 index 00000000..b501bd7b --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_228_setConnAttribute_clientbuffermaxkbsize.phpt @@ -0,0 +1,94 @@ +--TEST-- +GitHub issue #228 - how max client buffer size affects the fetching of data +--DESCRIPTION-- +A pdo_sqlsrv variation of the example in GitHub issue 228, using PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE the connection attribute. +--SKIPIF-- + +--FILE-- +setAttribute(PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE, $size); + } catch (PDOException $e) { + if (strpos($e->getMessage(), $error) === false) { + echo $e->getMessage() . "\n"; + } + } +} + +try { + // Connect + $conn = connect(); + + $error = 'The PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE attribute is not a number or the number is not positive. Only positive numbers are valid for this attribute.'; + testErrors($conn, 0, $error); + testErrors($conn, 2.99, $error); + + // Create 2 tables + $tableName1 = 'pdo_228_1'; + $tableName2 = 'pdo_228_2'; + + createTable($conn,$tableName1, array("c1_int" => "int", "c2_varchar" => "varchar(1000)")); + insertRow($conn, $tableName1, array("c1_int" => 990021574, "c2_varchar" => ">vh~Ö.bÐ*äß/ÄAabýZâOüzr£ðAß+|~|OU¢a|U<ßrv.uCB.ÐÜh_î+ãå@üðöã,U+ßvuU:/ý_Öãî/ð|bB|_Zbua©r++BA¢z£.üî¢öåäözÜ¢ßb:aöCrÄ~ýZ¢uªÐö.hhßð*zÜÜß*ãüåýãÄ+åýüüaߢÃÐBî@~AZöÃOßC@äoÃuCÜ,ÐÄa:îäÄÖý:h*ouªuåvUz_ArßAªãaãvÐåAUüAB:¢Äz|öub<üZvößüå:ãÄ@r/ZAÄðÄÄvzîv~C/£|ýýbüÖ~£|Öå<Üa~/v@åAz©¢£U_ßhbaÃß,zz<ã¢|<ä©>öAuövÖ>abu,zå,+ß/ü/ª_bbB:ÃC~£ü/O©O©ªAª_,|a¢~ýý/b>ßC@/böîöh>~£ð+Bßr©ÄÐÖßã:bA@:>B:UAbããîÜ~uÜ£îCöÖ£©_ÜßzÐ+ÖýZb,A:<z.ãîÄzC@©*ä|ã._ßZOäb¢Cßovå+uv.£B~~b£ª|ÖÄîßö>©Ãbb|©©ðA£åO~âãüîuvÄÜýUzîOÖ/oOßO*>ªßzêÖÐböÄåbîðîÐa~©ßîÄßУ<î>åBã_ý*ah¢rOĪ,ßo¢¢a|BÖäzU£.B£@Ü,ßAÃ>,ðßß+ßÜ©|Ðr©bCðТüãz>AßðåÃ>bÄåÄ|Z~äÃ/Cb*£bð_/Ða@~AÜãO+ý*CîîÃzÄöÃa©+@vuz>î>©.Cv>hÃý>©Bä,ö~@~@r,AðCu@Ü,@U*ÐvöÃêuã.Öa*uZªoZ/ðÖ©ßv_<ÖvåÜÐÜOÐoðßðÃUýZÐB:+ÄÃã£")); + + createTable($conn,$tableName2, array("c1_int" => "int", "c2_varchar" => "varchar(max)")); + insertRow($conn, $tableName2, array("c1_int" => 990021574, "c2_varchar" => ">vh~Ö.bÐ*äß/ÄAabýZâOüzr£ðAß+|~|OU¢a|U<ßrv.uCB.ÐÜh_î+ãå@üðöã,U+ßvuU:/ý_Öãî/ð|bB|_Zbua©r++BA¢z£.üî¢öåäözÜ¢ßb:aöCrÄ~ýZ¢uªÐö.hhßð*zÜÜß*ãüåýãÄ+åýüüaߢÃÐBî@~AZöÃOßC@äoÃuCÜ,ÐÄa:îäÄÖý:h*ouªuåvUz_ArßAªãaãvÐåAUüAB:¢Äz|öub<üZvößüå:ãÄ@r/ZAÄðÄÄvzîv~C/£|ýýbüÖ~£|Öå<Üa~/v@åAz©¢£U_ßhbaÃß,zz<ã¢|<ä©>öAuövÖ>abu,zå,+ß/ü/ª_bbB:ÃC~£ü/O©O©ªAª_,|a¢~ýý/b>ßC@/böîöh>~£ð+Bßr©ÄÐÖßã:bA@:>B:UAbããîÜ~uÜ£îCöÖ£©_ÜßzÐ+ÖýZb,A:<z.ãîÄzC@©*ä|ã._ßZOäb¢Cßovå+uv.£B~~b£ª|ÖÄîßö>©Ãbb|©©ðA£åO~âãüîuvÄÜýUzîOÖ/oOßO*>ªßzêÖÐböÄåbîðîÐa~©ßîÄßУ<î>åBã_ý*ah¢rOĪ,ßo¢¢a|BÖäzU£.B£@Ü,ßAÃ>,ðßß+ßÜ©|Ðr©bCðТüãz>AßðåÃ>bÄåÄ|Z~äÃ/Cb*£bð_/Ða@~AÜãO+ý*CîîÃzÄöÃa©+@vuz>î>©.Cv>hÃý>©Bä,ö~@~@r,AðCu@Ü,@U*ÐvöÃêuã.Öa*uZªoZ/ðÖ©ßv_<ÖvåÜÐÜOÐoðßðÃUýZÐB:+ÄÃã£")); + + $size = 2; + $conn->setAttribute(PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE, $size); + $stmt = $conn->prepare("SELECT * FROM $tableName1", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED)); + $attr = $conn->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE')); + echo("Client Buffer Size in KB: $attr\n"); + $stmt->execute(); + $numRows = 0; + while ($result = $stmt->fetch()) { + $numRows++; + } + echo ("Number of rows: $numRows\n"); + + $size = 3; + $conn->setAttribute(PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE, $size); + $stmt = $conn->prepare("SELECT * FROM $tableName2", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED)); + $attr = $conn->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE')); + echo("Client Buffer Size in KB: $attr\n"); + $stmt->execute(); + $numRows = 0; + while ($result = $stmt->fetch()) { + $numRows++; + } + + echo ("Number of rows: $numRows\n"); + + $size = 1; + $conn->setAttribute(PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE, $size); + $stmt = $conn->prepare("SELECT * FROM $tableName2", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED)); + $attr = $conn->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE')); + echo("Client Buffer Size in KB: $attr\n"); + try { + $stmt->execute(); + echo "Expect this to fail!!\n"; + } catch (PDOException $e) { + var_dump($e->getMessage()); + } + + dropTable($conn, $tableName1); + dropTable($conn, $tableName2); + unset($stmt); + unset($conn); + print "Done"; +} catch (PDOException $e) { + var_dump($e->errorInfo); +} +?> + +--EXPECT-- +Client Buffer Size in KB: 2 +Number of rows: 1 +Client Buffer Size in KB: 3 +Number of rows: 1 +Client Buffer Size in KB: 1 +string(65) "SQLSTATE[IMSSP]: Memory limit of 1 KB exceeded for buffered query" +Done diff --git a/test/functional/sqlsrv/srv_228_sqlsrv_clientbuffermaxkbsize.phpt b/test/functional/sqlsrv/srv_228_sqlsrv_clientbuffermaxkbsize.phpt index 6b4d1100..2c0e1b42 100644 --- a/test/functional/sqlsrv/srv_228_sqlsrv_clientbuffermaxkbsize.phpt +++ b/test/functional/sqlsrv/srv_228_sqlsrv_clientbuffermaxkbsize.phpt @@ -1,5 +1,7 @@ --TEST-- -sqlsrv_has_rows() using a forward and scrollable cursor +GitHub issue #228 - how ClientBufferMaxKBSize affects sqlsrv_has_rows and sqlsrv_fetch_array +--DESCRIPTION-- +Based on the example in GitHub issue 228, configuring ClientBufferMaxKBSize with sqlsrv_configure. --SKIPIF-- --FILE-- @@ -7,6 +9,20 @@ sqlsrv_has_rows() using a forward and scrollable cursor require_once('MsCommon.inc'); +function testErrors($conn) +{ + // set client buffer size to 0KB returns false + $ret = sqlsrv_configure('ClientBufferMaxKBSize', 0); + if (!$ret) { + echo sqlsrv_errors()[0]['message'] . "\n"; + } + + $ret = sqlsrv_configure('ClientBufferMaxKBSize', -1.9); + if (!$ret) { + echo sqlsrv_errors()[0]['message'] . "\n"; + } +} + function fetchData($conn, $table, $size) { $ret = sqlsrv_configure('ClientBufferMaxKBSize', $size); @@ -16,10 +32,13 @@ function fetchData($conn, $table, $size) echo("ClientBufferMaxKBSize is $attr\n"); sqlsrv_execute($stmt); + if ($size < 2) { + echo sqlsrv_errors()[0]['message'] . "\n"; + } + $rows = sqlsrv_has_rows($stmt); var_dump($rows); - sqlsrv_execute($stmt); $numRowsFetched = 0; while ($row = sqlsrv_fetch_array($stmt)) { $numRowsFetched++; @@ -40,18 +59,17 @@ $stmt = AE\createTable($conn, $tableName1, $columns); unset($columns); $columns = array(new AE\ColumnMeta('int', 'c1_int'), - new AE\ColumnMeta('varchar(1036)', 'c2_varchar_1036')); + new AE\ColumnMeta('varchar(1400)', 'c2_varchar_1400')); $stmt = AE\createTable($conn, $tableName2, $columns); -// insert > 1KB into c2_varchar_max & c2_varchar_1036 (1036 characters). -$longString = 'This is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a testThis is a test'; +// insert > 1KB into c2_varchar_max & c2_varchar_1400 (1400 characters). +$longString = str_repeat('This is a test', 100); $stmt = AE\insertRow($conn, $tableName1, array('c1_int' => 1, 'c2_varchar_max' => $longString)); -$stmt = AE\insertRow($conn, $tableName2, array('c1_int' => 1, 'c2_varchar_1036' => $longString)); +$stmt = AE\insertRow($conn, $tableName2, array('c1_int' => 1, 'c2_varchar_1400' => $longString)); +sqlsrv_free_stmt($stmt); -// set client buffer size to 0KB returns false -$ret = sqlsrv_configure('ClientBufferMaxKBSize', 0); -var_dump($ret); +testErrors($conn); // set client buffer size to 1KB $size = 1; @@ -62,19 +80,24 @@ $size = 2; fetchData($conn, $tableName1, $size); // this should return 1 row. fetchData($conn, $tableName2, $size); // this should return 1 row. -sqlsrv_free_stmt($stmt); +dropTable($conn, $tableName1); +dropTable($conn, $tableName2); + sqlsrv_close($conn); print "Done" ?> --EXPECT-- -bool(false) +Setting for ClientBufferMaxKBSize was non-int or non-positive. +Setting for ClientBufferMaxKBSize was non-int or non-positive. bool(true) ClientBufferMaxKBSize is 1 +Memory limit of 1 KB exceeded for buffered query bool(false) Number of rows fetched: 0 bool(true) ClientBufferMaxKBSize is 1 +Memory limit of 1 KB exceeded for buffered query bool(false) Number of rows fetched: 0 bool(true) diff --git a/test/functional/sqlsrv/srv_228_sqlsrv_clientbuffermaxkbsize_option.phpt b/test/functional/sqlsrv/srv_228_sqlsrv_clientbuffermaxkbsize_option.phpt new file mode 100644 index 00000000..459169d9 --- /dev/null +++ b/test/functional/sqlsrv/srv_228_sqlsrv_clientbuffermaxkbsize_option.phpt @@ -0,0 +1,109 @@ +--TEST-- +GitHub issue #228 - how ClientBufferMaxKBSize affects sqlsrv_has_rows and sqlsrv_fetch_array +--DESCRIPTION-- +A variation of the example in GitHub issue 228, using ClientBufferMaxKBSize the statement option. +--SKIPIF-- + +--FILE-- +"buffered", "ClientBufferMaxKBSize" => 0)); + if ($stmt !== false) { + echo("Setting client buffer size to 0KB should have failed\n"); + } else { + if (strpos(sqlsrv_errors()[0]['message'], $error) === false) { + print_r(sqlsrv_errors()); + } + } + + // set client buffer size to 0.99KB + $stmt = sqlsrv_prepare($conn, $query, array(), array("Scrollable"=>"buffered", "ClientBufferMaxKBSize" => 0.99)); + if ($stmt !== false) { + echo("Setting client buffer size to 0.99KB should have failed\n"); + } else { + if (strpos(sqlsrv_errors()[0]['message'], $error) === false) { + print_r(sqlsrv_errors()); + } + } +} + +function fetchData($conn, $table, $size) +{ + $stmt = sqlsrv_prepare($conn, "SELECT * FROM $table", array(), array("Scrollable"=>"buffered", "ClientBufferMaxKBSize" => $size)); + + $numRowsExpected = ($size > 1) ? 1 : 0; + $res = sqlsrv_execute($stmt); + if ($res && $size < 2) { + echo "Expect this to fail\n"; + } else { + $error = 'Memory limit of 1 KB exceeded for buffered query'; + if (strpos(sqlsrv_errors()[0]['message'], $error) === false) { + print_r(sqlsrv_errors()); + } + } + + $rows = sqlsrv_has_rows($stmt); + if ($numRowsExpected && !$rows) { + fatalError("sqlsrv_has_rows failed\n"); + } + + $numRowsFetched = 0; + while ($row = sqlsrv_fetch_array($stmt)) { + $numRowsFetched++; + } + if ($numRowsExpected != $numRowsFetched) { + echo("Expected $numRowsExpected but number of rows fetched is $numRowsFetched\n"); + } +} + +// connect +$conn = AE\connect(); + +$tableName1 = 'php_test_table_1'; +$tableName2 = 'php_test_table_2'; + +// Create tables +$columns = array(new AE\ColumnMeta('int', 'c1_int'), + new AE\ColumnMeta('varchar(max)', 'c2_varchar_max')); +$stmt = AE\createTable($conn, $tableName1, $columns); + +unset($columns); +$columns = array(new AE\ColumnMeta('int', 'c1_int'), + new AE\ColumnMeta('varchar(1050)', 'c2_varchar_1050')); +$stmt = AE\createTable($conn, $tableName2, $columns); + +// insert > 1KB into c2_varchar_max & c2_varchar_1050 (1050 characters). +$longString = str_repeat('This is a test', 75); + +$stmt = AE\insertRow($conn, $tableName1, array('c1_int' => 1, 'c2_varchar_max' => $longString)); +$stmt = AE\insertRow($conn, $tableName2, array('c1_int' => 1, 'c2_varchar_1050' => $longString)); +sqlsrv_free_stmt($stmt); + +$error = 'Setting for ClientBufferMaxKBSize was non-int or non-positive'; +testErrors($conn, $tableName1, $error); + +// set client buffer size to 1KB +$size = 1; +fetchData($conn, $tableName1, $size); // this should return 0 rows. +fetchData($conn, $tableName2, $size); // this should return 0 rows. +// set client buffer size to 2KB +$size = 2; +fetchData($conn, $tableName1, $size); // this should return 1 row. +fetchData($conn, $tableName2, $size); // this should return 1 row. + +dropTable($conn, $tableName1); +dropTable($conn, $tableName2); + +sqlsrv_close($conn); +print "Done" +?> + +--EXPECT-- +Done