MSSQL returning wrong result

Discussion about the open-source Phalanger [?] project.

MSSQL returning wrong result

Postby kripper » March 20th, 2015, 11:40 pm

I discovered something weird with the managed MSSQL extension.

When I use mssql_connect('host,1344', 'user', 'pass') providing a port number, after some queries, mssql_fetch_assoc() returns a wrong result = array("computed" => 1) instead if a valid result.

When I connect using mssql_connect('host', 'user', 'pass') without the port, it always works as expected.

I will now provide more details in order to guess what could be the reason for this weird behaviour:

1) For this code...

Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
mssql_select_db($db);
mssql_query("SET DATEFORMAT ymd");

$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);


...the result fails each 3 times (always) returning array('computed' => 1) for any $sql.

2) For this code...

Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
mssql_select_db($db);
// mssql_query("SET DATEFORMAT ymd");

$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);


...the result fails each 3 times (always) returning NULL for any $sql.

3) For this code...

Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
// mssql_select_db($db);
// mssql_query("SET DATEFORMAT ymd");

$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);


...it "never" fails (I tried about 20 times).

4) For this code...

Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
// mssql_select_db($db);
mssql_query("SET DATEFORMAT ymd");

$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);


...the result fails each 3 times (always) returning array('computed' => 1) for any $sql.

5) For this code...

Code: Select all
mssql_pconnect($host, $user, $pass);
mssql_select_db($db);
mssql_query("SET DATEFORMAT ymd");

$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);


...it "never" fails (I tried about 20 times).

6) If I repeat the query (in the same request / connection) many times...

Code: Select all
mssql_pconnect($host . ',' . $port, $user, $pass);
mssql_select_db($db);
mssql_query("SET DATEFORMAT ymd");

// Result will only fail here each 3 requests
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);

// It "never" fails here
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);

// Nor here
$cur = mssql_query("SELECT 'ok' AS test");
$res = mssql_fetch_assoc($cur);
...


...it only fails each 3 requests for the first query, but not the other ones.

Remarks:

It seems like it is related with the fact that I'm providing a port number ("host,port") and using mssql_select_db('dbname').

I'm running this code on Mono (Mono JIT compiler version 2.11.4) on CentOS Linux.

I don't have problems accessing the SQL Server with "host" or "host,port" from MS Visual Studio's Database Explorer.

Any idea what could be the problem?
kripper
 
Posts: 44
Joined: February 19th, 2012, 1:02 am

Re: MSSQL returning wrong result

Postby Jakub Misek » March 21st, 2015, 10:06 am

As I know, port number should be specified after ':' character.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: MSSQL returning wrong result

Postby kripper » March 27th, 2015, 3:21 pm

1) Separating port with ':' worked fine for Windows with php_dblib.dll and Linux with php_mssql.so.
But with Phalanger on Mono, ':' doesn't work, but ',' works fine.
I will take a look at mono's SQL implementation when I have some time.

2) I noticed that the even when not passing the port, the issue is still present, but less frequent.

Please, ignore/close this ticket, since it is probably not related with Phalanger but other components.

Thanks.
kripper
 
Posts: 44
Joined: February 19th, 2012, 1:02 am


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 20 guests

cron

User Control Panel

Login

Who is online

In total there are 20 users online :: 0 registered, 0 hidden and 20 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 20 guests