-
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.
Workaround for a bug in unixODBC 2.3.4 (#334)
* Adding a workaround for the error handling issue with unixODBC 2.3.4 when conneciton pooling is enabled * Adding a check to apply the workaround only to PDO SQLSRV * Update core_util.cpp * Unix Conn Pool test * Modifying the test to use autonomous_setup.php * Updating path to isPooled.php
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--TEST-- | ||
PDO Connection Pooling Test on Unix | ||
This test assumes odbcinst.ini has not been modified. | ||
This test also requires root privileges to modify odbcinst.ini file on Linux. | ||
--SKIPIF-- | ||
<?php if(PHP_OS === "WINNT") die("Skipped: Test for Linux and Mac"); | ||
--FILE-- | ||
<?php | ||
$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n"; | ||
|
||
//get odbcinst.ini location | ||
$lines = explode("\n", shell_exec("odbcinst -j")); | ||
$odbcinst_ini = explode(" ", $lines[1])[1]; | ||
|
||
//enable pooling by modifying the odbcinst.ini file | ||
$current = file_get_contents($odbcinst_ini); | ||
$current.=$lines_to_add; | ||
file_put_contents($odbcinst_ini, $current); | ||
|
||
//Creating a new php process, because for changes in odbcinst.ini file to affect pooling, drivers must be reloaded. | ||
print_r(shell_exec("php ./test/pdo_sqlsrv/isPooled.php")); | ||
|
||
//disable pooling by modifying the odbcinst.ini file | ||
$current = file_get_contents($odbcinst_ini); | ||
$current = str_replace("CPTimeout=5\n[ODBC]\nPooling=Yes\n",'',$current); | ||
file_put_contents($odbcinst_ini, $current); | ||
|
||
print_r(shell_exec("php ./test/pdo_sqlsrv/isPooled.php")); | ||
?> | ||
--EXPECT-- | ||
Pooled | ||
Not Pooled | ||
|
||
|
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,25 @@ | ||
<?php | ||
include_once 'autonomous_setup.php'; | ||
$conn1 = new PDO("sqlsrv:Server=$serverName", $username, $password); | ||
$connId1 = ConnectionID($conn1); | ||
$conn1 = null; | ||
|
||
$conn2 = new PDO("sqlsrv:Server=$serverName", $username, $password); | ||
$connId2 = ConnectionID($conn2); | ||
|
||
if ($connId1 === $connId2){ | ||
echo "Pooled\n"; | ||
}else{ | ||
echo "Not Pooled\n"; | ||
} | ||
|
||
function ConnectionID($conn) | ||
{ | ||
$tsql = "SELECT [connection_id] FROM [sys].[dm_exec_connections] where session_id = @@SPID"; | ||
$stmt = $conn->query($tsql); | ||
$connID = $stmt->fetchColumn(0); | ||
$stmt->closeCursor(); | ||
$stmt = null; | ||
return ($connID); | ||
} | ||
?> |