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

Driver injection produces the wrong error message on Linux #430

Open
david-puglielli opened this Issue Jun 9, 2017 · 3 comments

Comments

3 participants
@david-puglielli
Member

david-puglielli commented Jun 9, 2017

See test/sqlsrv/sqlsrv_testConnection.phpt. When running on Linux, this test fails at the stage labelled Test sqlsrv_connect with driver injection with the following error message:

array(2) {
  [0]=>
  array(6) {
    [0]=>
    string(5) "IMSSP"
    ["SQLSTATE"]=>
    string(5) "IMSSP"
    [1]=>
    int(-49)
    ["code"]=>
    int(-49)
    [2]=>
    string(206) "This extension requires the Microsoft ODBC Driver 11 or 13 for SQL Server. Access the following URL to download the ODBC Driver 11 or 13 for SQL Server for x64: http://go.microsoft.com/fwlink/?LinkId=163712"
    ["message"]=>
    string(206) "This extension requires the Microsoft ODBC Driver 11 or 13 for SQL Server. Access the following URL to download the ODBC Driver 11 or 13 for SQL Server for x64: http://go.microsoft.com/fwlink/?LinkId=163712"
  }
  [1]=>
  array(6) {
    [0]=>
    string(5) "IM002"
    ["SQLSTATE"]=>
    string(5) "IM002"
    [1]=>
    int(0)
    ["code"]=>
    int(0)
    [2]=>
    string(85) "[unixODBC][Driver Manager]Data source name not found, and no default driver specified"
    ["message"]=>
    string(85) "[unixODBC][Driver Manager]Data source name not found, and no default driver specified"
  }
}

This is obviously incorrect, as it is displayed even if the driver is already installed. It should instead produce an error stating that the login has failed. The incorrect error is returned from a call to SQLGetDiagField() in core_conn.cpp.

@Hadis-Fard

This comment has been minimized.

Show comment
Hide comment
@Hadis-Fard

Hadis-Fard Jun 9, 2017

Member

Could add a simple repo script to the issue? the test in not in the repo yet

Member

Hadis-Fard commented Jun 9, 2017

Could add a simple repo script to the issue? the test in not in the repo yet

@Hadis-Fard

This comment has been minimized.

Show comment
Hide comment
@Hadis-Fard

Hadis-Fard Jun 9, 2017

Member

what is the expected behavior?

Member

Hadis-Fard commented Jun 9, 2017

what is the expected behavior?

@david-puglielli

This comment has been minimized.

Show comment
Hide comment
@david-puglielli

david-puglielli Jun 9, 2017

Member

The following script will reproduce the error:

<?php
$server = 'myserver';
$pwd = 'mypassword';

$conn = sqlsrv_connect( $server, array( "UID" => "sa", "PWD" => "$pwd;Driver={SQL Server Native Client 11.0}}" ));
if( !$conn ) 
{
    var_dump( sqlsrv_errors() );
}
?>

The expected output is

array(2) {
  [0]=>
  array(6) {
    [0]=>
    string(5) "28000"
    ["SQLSTATE"]=>
    string(5) "28000"
    [1]=>
    int(18456)
    ["code"]=>
    int(18456)
    [2]=>
    string(81) "[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'."
    ["message"]=>
    string(81) "[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'."
  }
  [1]=>
  array(6) {
    [0]=>
    string(5) "28000"
    ["SQLSTATE"]=>
    string(5) "28000"
    [1]=>
    int(18456)
    ["code"]=>
    int(18456)
    [2]=>
    string(81) "[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'."
    ["message"]=>
    string(81) "[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'."
  }
}
Member

david-puglielli commented Jun 9, 2017

The following script will reproduce the error:

<?php
$server = 'myserver';
$pwd = 'mypassword';

$conn = sqlsrv_connect( $server, array( "UID" => "sa", "PWD" => "$pwd;Driver={SQL Server Native Client 11.0}}" ));
if( !$conn ) 
{
    var_dump( sqlsrv_errors() );
}
?>

The expected output is

array(2) {
  [0]=>
  array(6) {
    [0]=>
    string(5) "28000"
    ["SQLSTATE"]=>
    string(5) "28000"
    [1]=>
    int(18456)
    ["code"]=>
    int(18456)
    [2]=>
    string(81) "[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'."
    ["message"]=>
    string(81) "[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'."
  }
  [1]=>
  array(6) {
    [0]=>
    string(5) "28000"
    ["SQLSTATE"]=>
    string(5) "28000"
    [1]=>
    int(18456)
    ["code"]=>
    int(18456)
    [2]=>
    string(81) "[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'."
    ["message"]=>
    string(81) "[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'."
  }
}

@david-puglielli david-puglielli added this to Backlog in msphpsql Jun 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment