# [FIX] Bug #25585: PHP crash if executed MSSQL-query with RAISERROR() call and error 515

- Thread: https://externals.io/message/5934
- Original archive: https://news-web.php.net/php.internals/5934
- Started by Frank M. Kromann on 2003-12-01T19:02:28+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #5934 — Frank M. Kromann — 2003-12-01T19:02:28+00:00

URL: https://externals.io/message/5934#5934

This does not fix the problem.

mssql_query is designed to stop fetching for each result. Use
mssql_next_result() to move the internal pointer to the nex result and
process the data.

I have tested the code provided with the bug report and it works as I
expect (no crash).

- Frank

> I believe the problem here is in how mssql_query handles result sets
> that have multiple results returned, but none with rows (such as in
> this bug where there are multiple commands executed and multiple errors
> returned).  In the php_mssql.c for PHP 4.3.4 the block at line 1145
> reads:
> 
> 	while ((num_fields = dbnumcols(mssql_ptr->link)) <= 0 && retvalue ==
> SUCCEED) {
> 		retvalue = dbresults(mssql_ptr->link);
> 	}
> 
> According to Microsoft
> (http://msdn.microsoft.com/library/en-us/dblibc/dbc_pdc04e_52sz.asp),
> however:
> 
> 	"You must call dbresults until it returns NO_MORE_RESULTS, or 
> 	any continued use of the DBPROCESS causes the DB-Library error
> 	10038 'Results Pending'."
> 
> As this code in php_mssql.c currently stands it stops looping the empty
> result sets too early becuase it's looking for SUCCEED instead of
> NO_MORE_RESULTS.  Changing this code to:
> 
> 	while ((num_fields = dbnumcols(mssql_ptr->link)) <= 0 && retvalue !=
> NO_MORE_RESULTS) {
> 		retvalue = dbresults(mssql_ptr->link);
> 	}
> 
> causes both SQL Server error messages generated by the sample query in
> the bug report to be correctly displayed and eliminates the fault.
> 
> Michael Sisolak
> msisolak@yahoo.com
> 
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/

---

## #5960 — Michael Sisolak — 2003-12-01T22:52:49+00:00

URL: https://externals.io/message/5934#5960 · In reply to: #5934

Frank,

Hummm... I am seeing the crash on my development machine.  Using PHP
4.3.4 recompiled with the most recent php_mssql.c (1.86.2.26) this code
fails for me exactly as descibed in the bug report when run with the
CLI under Windows 2000 Professional.  I'm running SQL Server 2000 SP3
with version 8.00.194 of ntwdblib.dll.  What is your configuration?

Michael

--- "Frank M. Kromann" <frank@kromann.info> wrote:
> This does not fix the problem.
> 
> mssql_query is designed to stop fetching for each result. Use
> mssql_next_result() to move the internal pointer to the nex result
> and
> process the data.
> 
> I have tested the code provided with the bug report and it works as I
> expect (no crash).
> 
> - Frank
> 
> > […]
> sets
> > […]
> errors
> > […]
> ==
> > […]
> (http://msdn.microsoft.com/library/en-us/dblibc/dbc_pdc04e_52sz.asp),
> > […]
> empty
> > […]
> !=
> > […]
> in
> > […]
> 
> 
> 


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
