{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/msphpsql/issues/733","repository_url":"https://api.github.com/repos/Microsoft/msphpsql","labels_url":"https://api.github.com/repos/Microsoft/msphpsql/issues/733/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/msphpsql/issues/733/comments","events_url":"https://api.github.com/repos/Microsoft/msphpsql/issues/733/events","html_url":"https://github.com/Microsoft/msphpsql/issues/733","id":310785431,"number":733,"title":"PDO::getAttribute(PDO::ATTR_SERVER_VERSION) fails on connection from connection pool","user":{"login":"mathieuk","id":539914,"avatar_url":"https://avatars3.githubusercontent.com/u/539914?v=4","gravatar_id":"","url":"https://api.github.com/users/mathieuk","html_url":"https://github.com/mathieuk","followers_url":"https://api.github.com/users/mathieuk/followers","following_url":"https://api.github.com/users/mathieuk/following{/other_user}","gists_url":"https://api.github.com/users/mathieuk/gists{/gist_id}","starred_url":"https://api.github.com/users/mathieuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathieuk/subscriptions","organizations_url":"https://api.github.com/users/mathieuk/orgs","repos_url":"https://api.github.com/users/mathieuk/repos","events_url":"https://api.github.com/users/mathieuk/events{/privacy}","received_events_url":"https://api.github.com/users/mathieuk/received_events","type":"User","site_admin":false},"labels":[{"id":718216387,"url":"https://api.github.com/repos/Microsoft/msphpsql/labels/unixODBC","name":"unixODBC","color":"4aefad","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-03T10:46:17Z","updated_at":"2018-04-18T14:54:15Z","closed_at":null,"author_association":"NONE","body":"## Driver version or file name\r\nextension version 4.3.0 (per `php -i`) \r\n\r\n## SQL Server version\r\nSQL2016\r\n \r\n## Client operating system\r\nCentOS Linux release 7.4.1708 (Core)\r\n\r\n## PHP version\r\nPHP 7.1.15\r\n\r\n## Microsoft ODBC Driver version\r\n13.1.9.2 (per `yum info msodbcsql`) \r\n\r\n## Problem description\r\nWhen using connection pooling requesting the Server Version attribute (PDO::ATTR_SERVER_VERSION) the request fails on the second request in the same process. \r\n\r\nThe reason that I ran into this quite specific problem is that the framework used (Laravel) uses Doctrine/DBAL which checks this attribute (see https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Driver/PDOConnection.php#L71). The code below is thus simplified. \r\n\r\n## Expected behavior and actual behavior\r\nExpected behaviour was to receive a value for the attribute.\r\n\r\nActual behaviour is the code works fine for a non-connection-pool-connection (`Pooling=no` in `odbcinst.ini`) but a warning is thrown by PDO::getAttribute() when the connection would be from the connection pool:\r\n \r\n`PHP Warning:  PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in /path/to/test.php on line 6`\r\n\r\n## Repro code\r\n/etc/odbcinst.ini:\r\n```\r\n[ODBC]\r\nPooling=Yes\r\n\r\n[ODBC Driver 13 for SQL Server]\r\nDescription=Microsoft ODBC Driver 13 for SQL Server\r\nDriver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.2\r\nUsageCount=1\r\nCPTimeout=120\r\n```\r\n\r\ntest.php: \r\n```php\r\n<?php\r\n\r\nfor ($i = 0; $i < 4; $i++) { \r\n    $pdo = new PDO('sqlsrv:Server=HOSTNAMEGOESHERE;Database=EXISTINGDATABASEGOESHERE', 'user', 'password');\r\n    var_dump($pdo->getAttribute(PDO::ATTR_SERVER_VERSION));\r\n    echo \"----------------------------------\\n\";\r\n}\r\n\r\n?>\r\n```\r\nExpected result: \r\n\r\n```\r\nstring(10) \"13.00.4001\"\r\n----------------------------------\r\nstring(10) \"13.00.4001\"\r\n----------------------------------\r\nstring(10) \"13.00.4001\"\r\n----------------------------------\r\nstring(10) \"13.00.4001\"\r\n----------------------------------\r\n```\r\n\r\nActual result:\r\n```\r\nstring(10) \"13.00.4001\"\r\n----------------------------------\r\nstring(10) \"13.00.4001\"\r\n----------------------------------\r\nPHP Warning:  PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in test.php on line 6\r\nbool(false)\r\n----------------------------------\r\nPHP Warning:  PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in test.php on line 6\r\nbool(false)\r\n----------------------------------\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/msphpsql/issues/comments/382415663","html_url":"https://github.com/Microsoft/msphpsql/issues/733#issuecomment-382415663","issue_url":"https://api.github.com/repos/Microsoft/msphpsql/issues/733","id":382415663,"user":{"login":"mathieuk","id":539914,"avatar_url":"https://avatars3.githubusercontent.com/u/539914?v=4","gravatar_id":"","url":"https://api.github.com/users/mathieuk","html_url":"https://github.com/mathieuk","followers_url":"https://api.github.com/users/mathieuk/followers","following_url":"https://api.github.com/users/mathieuk/following{/other_user}","gists_url":"https://api.github.com/users/mathieuk/gists{/gist_id}","starred_url":"https://api.github.com/users/mathieuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathieuk/subscriptions","organizations_url":"https://api.github.com/users/mathieuk/orgs","repos_url":"https://api.github.com/users/mathieuk/repos","events_url":"https://api.github.com/users/mathieuk/events{/privacy}","received_events_url":"https://api.github.com/users/mathieuk/received_events","type":"User","site_admin":false},"created_at":"2018-04-18T14:54:15Z","updated_at":"2018-04-18T14:54:15Z","author_association":"NONE","body":"This indeed seems fixed with a more up to date unixODBC. Thanks for looking into this!"}}
{"actor":{"display_login":"mathieuk"}}