-
Notifications
You must be signed in to change notification settings - Fork 373
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
Include sql_variant type for buffered queries #1080
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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
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
59 changes: 59 additions & 0 deletions
59
test/functional/pdo_sqlsrv/pdo_1079_sql_variant_buffered_queries.phpt
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,59 @@ | ||
--TEST-- | ||
GitHub issue 1079 - fetching sql_variant types using client buffers | ||
--DESCRIPTION-- | ||
This test verifies that fetching sql_variant types using client buffers is supported. | ||
--ENV-- | ||
PHPT_EXEC=true | ||
--SKIPIF-- | ||
<?php require('skipif_mid-refactor.inc'); ?> | ||
--FILE-- | ||
<?php | ||
require_once("MsSetup.inc"); | ||
require_once("MsCommon_mid-refactor.inc"); | ||
|
||
try { | ||
$conn = connect(); | ||
|
||
$funcName = 'PDO1079'; | ||
dropFunc($conn, $funcName); | ||
|
||
$tsql = "CREATE FUNCTION [$funcName](@OP1 sql_variant, @OP2 sql_variant) RETURNS sql_variant AS | ||
BEGIN DECLARE @Result sql_variant SET @Result = CASE WHEN @OP1 >= @OP2 THEN @OP1 ELSE @OP2 END RETURN @Result END"; | ||
|
||
$conn->exec($tsql); | ||
|
||
$tsql = "SELECT [dbo].[$funcName](5, 6) AS RESULT"; | ||
$stmt = $conn->prepare($tsql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED)); | ||
$stmt->execute(); | ||
|
||
$metadata = $stmt->getColumnMeta(0); | ||
var_dump($metadata); | ||
|
||
dropFunc($conn, $funcName); | ||
|
||
unset($stmt); | ||
unset($conn); | ||
} catch (PdoException $e) { | ||
echo $e->getMessage() . PHP_EOL; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
array(8) { | ||
["flags"]=> | ||
int(0) | ||
["sqlsrv:decl_type"]=> | ||
string(11) "sql_variant" | ||
["native_type"]=> | ||
string(6) "string" | ||
["table"]=> | ||
string(0) "" | ||
["pdo_type"]=> | ||
int(2) | ||
["name"]=> | ||
string(6) "RESULT" | ||
["len"]=> | ||
int(10) | ||
["precision"]=> | ||
int(0) | ||
} |
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
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
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
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
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
62 changes: 62 additions & 0 deletions
62
test/functional/sqlsrv/srv_1079_sql_variant_buffered_queries.phpt
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,62 @@ | ||
--TEST-- | ||
GitHub issue 1079 - fetching sql_variant types using client buffers | ||
--DESCRIPTION-- | ||
This test verifies that fetching sql_variant types using client buffers is supported. | ||
--ENV-- | ||
PHPT_EXEC=true | ||
--SKIPIF-- | ||
<?php require('skipif_versions_old.inc'); ?> | ||
--FILE-- | ||
<?php | ||
require_once('MsCommon.inc'); | ||
|
||
$conn = AE\connect(); | ||
|
||
$funcName = 'SRV1079'; | ||
dropFunc($conn, $funcName); | ||
|
||
$tsql = "CREATE FUNCTION [$funcName](@OP1 sql_variant, @OP2 sql_variant) RETURNS sql_variant AS | ||
BEGIN DECLARE @Result sql_variant SET @Result = CASE WHEN @OP1 >= @OP2 THEN @OP1 ELSE @OP2 END RETURN @Result END"; | ||
|
||
$stmt = sqlsrv_query($conn, $tsql); | ||
if (!$stmt) { | ||
fatalError('Could not create function\n'); | ||
} | ||
|
||
$tsql = "SELECT [dbo].[$funcName](5, 6) AS RESULT"; | ||
$stmt = sqlsrv_prepare($conn, $tsql, array(), array("Scrollable" => SQLSRV_CURSOR_CLIENT_BUFFERED, "ClientBufferMaxKBSize" => 1000)); | ||
|
||
if (!$stmt) { | ||
fatalError('Could not prepare query\n'); | ||
} | ||
|
||
$result = sqlsrv_execute($stmt); | ||
if (!$result) { | ||
fatalError('Executing the query failed\n'); | ||
} | ||
|
||
foreach (sqlsrv_field_metadata($stmt) as $fieldMetadata) { | ||
var_dump($fieldMetadata); | ||
} | ||
|
||
dropFunc($conn, $funcName); | ||
|
||
sqlsrv_free_stmt($stmt); | ||
sqlsrv_close($conn); | ||
|
||
?> | ||
--EXPECT-- | ||
array(6) { | ||
["Name"]=> | ||
string(6) "RESULT" | ||
["Type"]=> | ||
int(-150) | ||
["Size"]=> | ||
int(10) | ||
["Precision"]=> | ||
NULL | ||
["Scale"]=> | ||
NULL | ||
["Nullable"]=> | ||
int(1) | ||
david-puglielli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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.
This installs the ubuntu version of SQL Server?
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.
Yes, please scroll down this page for your reference