Fixed output for sqlsrv connres tests

This commit is contained in:
David Puglielli 2018-07-19 16:18:03 -07:00
parent 6f0f4b70db
commit 96efbdb47b
3 changed files with 26 additions and 98 deletions

View file

@ -144,7 +144,12 @@ $stmt6 = sqlsrv_query( $conn, "SELECT * FROM $tableName2" );
if( $stmt6 === false )
{
echo "Error in statement 6.\n";
print_r( sqlsrv_errors() );
$err = sqlsrv_errors();
if (strpos($err[0][0], '08S01')===false or !($err[0][1]==10054 or $err[0][1]==104) or
(strpos($err[0][2], 'TCP Provider:')===false and strpos($err[0][2], 'SMux Provider:')===false)) {
echo "Error: Wrong error message.\n";
print_r($err);
}
}
else
{
@ -188,7 +193,12 @@ $stmt8 = sqlsrv_query( $conn, "SELECT * FROM $tableName2" );
if( $stmt8 === false )
{
echo "Error in statement 8.\n";
print_r( sqlsrv_errors() );
$err = sqlsrv_errors();
if (strpos($err[0][0], 'IMSSP')===false or $err[0][1]!=-44 or
strpos($err[0][2], 'The connection cannot process this operation because there is a statement with pending results')===false) {
echo "Error: Wrong error message.\n";
print_r($err);
}
}
else
{
@ -199,7 +209,7 @@ sqlsrv_close( $conn );
sqlsrv_close( $conn_break );
?>
--EXPECTREGEX--
--EXPECT--
Statement 1 successful.
16 rows in result set.
Statement 2 successful.
@ -211,51 +221,5 @@ Statement 4 successful.
Statement 5 successful.
rows in result set.
Error in statement 6.
Array
\(
\[0\] => Array
\(
\[0\] => 08S01
\[SQLSTATE\] => 08S01
\[1\] => (10054|104)
\[code\] => (10054|104)
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]TCP Provider: (An existing connection was forcibly closed by the remote host\.\n|Error code 0x68|Error code 0x2746)
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]TCP Provider: (An existing connection was forcibly closed by the remote host\.\n|Error code 0x68|Error code 0x2746)
\)
\[1\] => Array
\(
\[0\] => 08S01
\[SQLSTATE\] => 08S01
\[1\] => (10054|104)
\[code\] => (10054|104)
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Communication link failure
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Communication link failure
\)
\)
Statement 7 successful.
Error in statement 8.
Array
\(
\[0\] => Array
\(
\[0\] => IMSSP
\[SQLSTATE\] => IMSSP
\[1\] => -44
\[code\] => -44
\[2\] => The connection cannot process this operation because there is a statement with pending results. To make the connection available for other queries, either fetch all results or cancel or free the statement. For more information, see the product documentation about the MultipleActiveResultSets connection option.
\[message\] => The connection cannot process this operation because there is a statement with pending results. To make the connection available for other queries, either fetch all results or cancel or free the statement. For more information, see the product documentation about the MultipleActiveResultSets connection option.
\)
\[1\] => Array
\(
\[0\] => HY000
\[SQLSTATE\] => HY000
\[1\] => 0
\[code\] => 0
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Connection is busy with results for another command
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Connection is busy with results for another command
\)
\)

View file

@ -167,40 +167,22 @@ else
else
{
echo "Statement not valid and rollback failed.\n";
print_r( sqlsrv_errors() );
$err = sqlsrv_errors();
if (strpos($err[0][0], '08S02')===false or !($err[0][1]==10054 or $err[0][1]==-1) or
(strpos($err[0][2], 'TCP Provider:')===false and strpos($err[0][2], 'SMux Provider:')===false)) {
echo "Error: Wrong error message.\n";
print_r($err);
}
}
}
sqlsrv_close( $conn );
sqlsrv_close( $conn_break );
?>
--EXPECTREGEX--
--EXPECT--
Statement 1 prepared.
Statement 1 executed.
Transaction begun.
Transaction was committed.
Transaction begun.
Statement not valid and rollback failed.
Array
\(
\[0\] => Array
\(
\[0\] => 08S02
\[SQLSTATE\] => 08S02
\[1\] => (10054|-1)
\[code\] => (10054|-1)
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\](TCP Provider: An existing connection was forcibly closed by the remote host\.\n|SMux Provider: Physical connection is not usable \[xFFFFFFFF\]\. )
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\](TCP Provider: An existing connection was forcibly closed by the remote host\.\n|SMux Provider: Physical connection is not usable \[xFFFFFFFF\]\. )
\)
\[1\] => Array
\(
\[0\] => 08S02
\[SQLSTATE\] => 08S02
\[1\] => (10054|-1)
\[code\] => (10054|-1)
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Unable to open a logical session
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Unable to open a logical session
\)
\)

View file

@ -33,7 +33,12 @@ $stmt1 = sqlsrv_query( $conn, "SELECT * FROM $tableName1" );
if( $stmt1 === false )
{
echo "Error in statement 1.\n";
print_r( sqlsrv_errors() );
$err = sqlsrv_errors();
if (strpos($err[0][0], '08S01')===false or !($err[0][1]==10054 or $err[0][1]==104) or
(strpos($err[0][2], 'TCP Provider:')===false and strpos($err[0][2], 'SMux Provider:')===false)) {
echo "Error: Wrong error message.\n";
print_r($err);
}
}
else
{
@ -78,27 +83,4 @@ DropTables( $server, $uid, $pwd, $tableName1, $tableName2 )
?>
--EXPECTREGEX--
Error in statement 1.
Array
\(
\[0\] => Array
\(
\[0\] => 08S01
\[SQLSTATE\] => 08S01
\[1\] => (10054|104)
\[code\] => (10054|104)
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]TCP Provider: (An existing connection was forcibly closed by the remote host\.\n|Error code 0x68|Error code 0x2746)
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]TCP Provider: (An existing connection was forcibly closed by the remote host\.\n|Error code 0x68|Error code 0x2746)
\)
\[1\] => Array
\(
\[0\] => 08S01
\[SQLSTATE\] => 08S01
\[1\] => (10054|104)
\[code\] => (10054|104)
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Communication link failure
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Communication link failure
\)
\)
Statement 2 successful.