-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a new test and modify a non LOB sqlsrv test #1000
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--TEST-- | ||
Test reading non LOB types | ||
--DESCRIPTION-- | ||
A simpler version of sqlsrv test "test_sqlsrv_phptype_stream.phpt" for reading from | ||
pre-populated tables [test_streamable_types] and [test_types] | ||
--SKIPIF-- | ||
<?php require('skipif_azure_dw.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
require('MsSetup.inc'); | ||
|
||
function verifyResult($result) | ||
{ | ||
if (empty($result) || !is_array($result)) { | ||
echo "Result is empty or not an array!\n"; | ||
return; | ||
} | ||
|
||
$trimmedLen = 200; | ||
$fullLen = 256; | ||
$input = str_repeat('A', $trimmedLen); | ||
for ($i = 0; $i < count($result); $i++) { | ||
$expectedLen = ($i % 2 == 0) ? $fullLen : $trimmedLen; | ||
$len = strlen($result[$i]); | ||
if ($len != $expectedLen) { | ||
echo "String length $len for column ". $i + 1 . " is unexpected!\n"; | ||
} | ||
|
||
$data = rtrim($result[$i]); | ||
if ($data !== $input) { | ||
echo "Result for column ". $i + 1 . " is unexpected:"; | ||
var_dump($result[$i]); | ||
} | ||
} | ||
} | ||
|
||
try { | ||
$conn = new PDO("sqlsrv:server=$server; Database = $databaseName", $uid, $pwd); | ||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
|
||
// test the allowed non LOB column types | ||
$tsql = "SELECT [char_short_type], [varchar_short_type], [nchar_short_type], [nvarchar_short_type], [binary_short_type], [varbinary_short_type] FROM [test_streamable_types]"; | ||
$stmt = $conn->query($tsql); | ||
|
||
$result = $stmt->fetch(PDO::FETCH_NUM); | ||
verifyResult($result); | ||
|
||
// test not streamable types | ||
$tsql = "SELECT * FROM [test_types]"; | ||
$stmt = $conn->query($tsql); | ||
$result = $stmt->fetch(PDO::FETCH_NUM); | ||
print_r($result); | ||
|
||
} catch (PDOException $e) { | ||
var_dump($e->errorInfo); | ||
} | ||
|
||
unset($stmt); | ||
unset($conn); | ||
|
||
?> | ||
--EXPECT-- | ||
Array | ||
( | ||
[0] => 9223372036854775807 | ||
[1] => 2147483647 | ||
[2] => 32767 | ||
[3] => 255 | ||
[4] => 1 | ||
[5] => 9999999999999999999999999999999999999 | ||
[6] => 922337203685477.5807 | ||
[7] => 214748.3647 | ||
[8] => 1.79E+308 | ||
[9] => 1.1799999E-38 | ||
[10] => 1968-12-12 16:20:00.000 | ||
[11] => | ||
) |
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unclear on what the purpose of this part is? I know the corresponding sqlsrv test tests fetching non-streamable types as streams, but since we can't stream data in pdo_sqlsrv is there any reason to have this part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly to create a similar pdo test for using both as tests used in stress testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok