-
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 test case for Issue 699 #773
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0bc4a36
Added test case for Issue 699
yitam 999312b
Tried using INT_MAX instead
yitam 9a82e9d
Used sizeof not INT_MAX
yitam bca3110
Modified the output param initial value
yitam 4c7c085
Added workaround for the test plus use BIGINT for 64-bit systems
yitam 0b5ceb0
Reverted the changes
yitam 4747537
Fixed the formatting
yitam 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--TEST-- | ||
GitHub issue #699 - binding integer as output parameter failed | ||
--DESCRIPTION-- | ||
This test uses the sample stored procedure provided by the user, in which an | ||
error situation caused the binding to fail with an irrelevant error message about UTF-8 translation. This test proves that this issue has been fixed. | ||
--ENV-- | ||
PHPT_EXEC=true | ||
--SKIPIF-- | ||
<?php require('skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
require_once('MsCommon.inc'); | ||
|
||
$connectionOptions = array("CharacterSet"=> "UTF-8", "ConnectionPooling"=>1); | ||
$conn = connect($connectionOptions); | ||
|
||
$tableName1 = "table_issue699_1"; | ||
$tableName2 = "table_issue699_2"; | ||
$procName = "proc_issue699"; | ||
|
||
dropTable($conn, $tableName1); | ||
dropTable($conn, $tableName2); | ||
dropProc($conn, $procName); | ||
|
||
// Create two test tables without encryption | ||
$sql = "CREATE TABLE $tableName1 (correio_electronico NVARCHAR(50), nome NVARCHAR(50), telefones NVARCHAR(15), id_entidade INT)"; | ||
$stmt = sqlsrv_query($conn, $sql); | ||
if (!$stmt) { | ||
fatalError("Failed to create table $tableName1\n"); | ||
} | ||
|
||
$sql = "CREATE TABLE $tableName2 (estado TINYINT NOT NULL DEFAULT 0)"; | ||
$stmt = sqlsrv_query($conn, $sql); | ||
if (!$stmt) { | ||
fatalError("Failed to create table $tableName2\n"); | ||
} | ||
|
||
// Create the stored procedure | ||
$sql = "CREATE PROCEDURE $procName @outparam INT OUTPUT AS | ||
BEGIN | ||
SET @outparam = 100; | ||
INSERT INTO $tableName1 (correio_electronico, nome, telefones, id_entidade) | ||
SELECT '[email protected]', 'Teste', 'xxx', 1 | ||
FROM $tableName2 CC | ||
WHERE CC.estado = 100 | ||
BEGIN TRY | ||
SET @outparam = 123 | ||
END TRY | ||
BEGIN CATCH | ||
END CATCH | ||
END"; | ||
|
||
$stmt = sqlsrv_query($conn, $sql); | ||
if (!$stmt) { | ||
fatalError("Error in creating the stored procedure $procName\n"); | ||
} | ||
|
||
$set_no_count = ""; | ||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'LIN') { | ||
// This test, when running outside of Windows, requires unixODBC 2.3.4 | ||
// or above (see the list of bug fixes in www.unixodbc.org) | ||
// Add this workaround for Linux platforms | ||
$set_no_count = "SET NOCOUNT ON; "; | ||
} | ||
|
||
$sql_callSP = $set_no_count . "{call $procName(?)}"; | ||
|
||
// Initialize the output parameter to any number | ||
$outParam = 1; | ||
$params = array(array(&$outParam, SQLSRV_PARAM_OUT)); | ||
$stmt = sqlsrv_query($conn, $sql_callSP, $params); | ||
if (!$stmt) { | ||
fatalError("Error in calling $procName\n"); | ||
} | ||
|
||
while ($res = sqlsrv_next_result($stmt)); | ||
|
||
if ($outParam != 123) { | ||
echo "The output param value $outParam is unexpected!\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think display the $outParam here so we can see immediately what it is if it fails. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it is being printed in the echo stmt as $outParm |
||
} | ||
|
||
dropTable($conn, $tableName1); | ||
dropTable($conn, $tableName2); | ||
dropProc($conn, $procName); | ||
|
||
// Free handles | ||
sqlsrv_free_stmt($stmt); | ||
sqlsrv_close($conn); | ||
|
||
echo "Done\n"; | ||
|
||
?> | ||
--EXPECT-- | ||
Done |
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.
So this is the only thing that has to change to get the test to pass in Linux?
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, because unixODBC later versions fixed some bugs related to "SQLMoreResults" or "SQL_NO_DATA". By setting nocount these calls are bypassed.