-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include sql_variant type for buffered queries (#1080)
- Loading branch information
Showing
11 changed files
with
169 additions
and
22 deletions.
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) | ||
} |