Req #63485 [Opn->Wfx]: I don't think the mssql_min_error_severity() function works as it should.

From: Date: Sat, 15 Oct 2016 23:16:56 +0000
Subject: Req #63485 [Opn->Wfx]: I don't think the mssql_min_error_severity() function works as it should.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204811@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63485&edit=1

 ID:                 63485
 Updated by:         kalle@php.net
 Reported by:        david at sickmiller dot com
 Summary:            I don't think the mssql_min_error_severity()
                     function works as it should.
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            MSSQL related
 Operating System:   CentOS 5.8
 PHP Version:        5.3.18
 Block user comment: N
 Private report:     N

 New Comment:

With MSSQL being removed from PHP as of PHP7.0, and ext/mssql not having a maintainer, I'm
gonna close this report as a Won't fix, until maybe one day it will find a new maintainer.

Alternatively you can use sqlsrv from Microsoft if you are on Windows, or pdo_dblib if you are on
Unix.


Previous Comments:
------------------------------------------------------------------------
[2012-11-11 12:20:45] david at sickmiller dot com

Description:
------------
Hi,

I don't think the mssql_min_error_severity() function works as it should.  At a minimum, the
one example in the manual does not make sense
(http://www.php.net/function.mssql-min-error-severity#refsect1-function.mssql-min-error-severity-examples).

The example uses a SQL statement with a syntax error.  Regardless of what you set
mssql_min_error_severity to, a syntax error is always going to trigger both (a) a PHP Warning and
(b) a false return value from mssql_query().  This behavior contradicts the comment above
mssql_min_error_severity(1);.  Also, since the code checks the return value from mssql_query(),
it's most likely the user will want to use @ to suppress the PHP Warning but that is not shown
in the example.

Here's an example that at least shows the mssql_min_error_severity() function doing something:

<?php
mssql_connect($host, $user, $pass);
mssql_select_db($dbname);
mssql_min_error_severity(16);
mssql_min_message_severity(16);
// This SQL has a severity 16 error -- subquery returns multiple rows
$query = mssql_query('SELECT *, (select error from master.dbo.sysmessages) as bad_subquery from
master.dbo.sysmessages');
// Prints:
//   PHP Warning:  mssql_query(): message: Subquery returned more than 1 value. This is not
permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as
an expression. (severity 16)
//   PHP Warning:  mssql_query(): General SQL Server error: Check messages from the SQL Server
(severity 16)

mssql_min_error_severity(17);
mssql_min_message_severity(17);
$query = mssql_query('SELECT *, (select error from master.dbo.sysmessages) as bad_subquery from
master.dbo.sysmessages');
// Prints nothing



Now, the behavior I disagree with relates to the return value from mssql_query().  Unlike the PHP
Warnings, it seems to be unaffected by the min severity settings.  Please see the test script
section.

Test script:
---------------
<?php
mssql_connect($host, $user, $pass);
mssql_select_db($dbname);
mssql_min_error_severity(16);
mssql_min_message_severity(16);

// This SQL has a severity 16 error -- subquery returns multiple rows
$query = @mssql_query('SELECT *, (select error from master.dbo.sysmessages) as bad_subquery
from master.dbo.sysmessages');
if (!$query) {
        echo "With min severity set to 16, inside custom error handler\n";
} else {
        echo "With min severity set to 16, return code indicates no error from
mssql_query()\n";
}


mssql_min_error_severity(17);
mssql_min_message_severity(17);

$query = @mssql_query('SELECT *, (select error from master.dbo.sysmessages) as bad_subquery
from master.dbo.sysmessages');
if (!$query) {
        echo "With min severity set to 17, inside custom error handler\n";
} else {
        echo "With min severity set to 17, return code indicates no error from
mssql_query()\n";
}

Expected result:
----------------
Expected output:

With min severity set to 16, inside custom error handler
With min severity set to 17, return code indicates no error from mssql_query()

Actual result:
--------------
Actual output:

With min severity set to 16, return code indicates no error from mssql_query()
With min severity set to 17, return code indicates no error from mssql_query()


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=63485&edit=1


Thread (2 messages)

« previous php.bugs (#204811) next »