From: snick at getart dot ru
Operating system: Windows 2003 Server
PHP version: 4.3.3
PHP Bug Type: MSSQL related
Bug description: PHP crash if executed MSSQL-query with RAISERROR() call and error 515
Description:
------------
When I try to execute T-SQL query with advanced instructions PHP was
crash.
Tested with:
Apache v. 2.0.43
IIS v. 6.0
MSSQL v. 7.0
ntwdblib.dll v. 2000.80.194.0
Query must include:
- BEGIN TRAN and COMMIT / ROLLBACK TRAN;
- RAISEERROR() function call;
- Error in query before RAISERROR (eg. failed INSERT with 'Can not insert
NULL into bla-bla-bla' message (msg 515))
Reproduce code:
---------------
// you must create database called 'myDB' and table
// 'myTable' with columns myField1 INT NOT NULL, myField2 VARCHAR(50) NOT
NULL
/*
...db connection and selection
*/
$query = "BEGIN TRAN
DECLARE @Flag BIT
SET @Flag = 0
INSERT INTO myTable (myField2) VALUES ('akgfsjhdgf')
IF @Flag = 0
BEGIN
RAISERROR('Some error', 18, 10)
ROLLBACK TRAN
END
ELSE
COMMIT TRAN";
$result = mssql_query($query);
echo "Result is ".($result ? "true" : "false")."<br/>";
echo "DB Error is ".mssql_get_last_message()."<br/>";
Expected result:
----------------
PHP must return usual errors (if exists) and specified output:
Result is true
DB Error is Changed database context to 'myDB'
Actual result:
--------------
If PHP running as Apache module:
message box
"Apache.exe - Application Error
The instruction at '0x77f486f7' referenced memory at
'0x00000000'. The memory could not be 'read'"
If PHP running as standalone:
message box
"php.exe - Application Error
The instruction at '0x77f486f7' referenced memory at
'0x00000000'. The memory could not be 'read'"
If PHP running as ISAPI module:
IIS return in browser string "PHP has encountered an Access Violation at
77F47931"
--
Edit bug report at http://bugs.php.net/?id=25585&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25585&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25585&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=25585&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=25585&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25585&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=25585&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=25585&r=support
Expected behavior: http://bugs.php.net/fix.php?id=25585&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=25585&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=25585&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=25585&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25585&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=25585&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=25585&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=25585&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25585&r=float