[OpenSER-Devel] presence load tests: 1.2.1 vs trunk with mysql

Henning Westerholt henning.westerholt at 1und1.de
Tue Jul 24 15:42:16 CEST 2007


On Friday 20 July 2007, Victor Gamov wrote:
> [..]
> For db_mysql_fetch result() when nrows==0 function do nothing and return
> 0.  But in this situation if user makes SELECT-like query and then call
> db_mysql_fetch_rows() with nrows=0 no mysql_store_result() called and it
> wrong because "you _must_ call mysql_store_result() or
> mysql_use_result() for every statement that successfully retrieves data"
> (http://dev.mysql.com/doc/refman/5.1/en/mysql-store-result.html)
>
> And it's really strange don't get any data and call
> db_mysql_fetch_rows() with nrows=0 after SELECT-like query
>
> Also there are no problems or "any notable performance degradation if
> you call mysql_store_result()  in all cases".
>
> So we can use nrows to realize different behavior for
> db_mysql_fetch_rows():
>
> -- nrows == 0 -- get complete result set. If called after non SELECT-like
> query it will call mysql_store_result() and mysql_field_count() and return
> 0
>
> -- nrows > 0 -- get result set and return nrows lines only
>
> -- if we want to fetch zero rows then we can use nrows < 0 (now looks like
> wrong parameter value), call mysql_store_result() and
> mysql_free_result() and return 0.

Hello Victor,

i changed the mysql db API to use the same behaviour as the postgresql driver. 
In my opinion this is the "correct" behaviour of the fetch_result function 
from the API point of view and matches the user expectations:

- nrows == 0 - don't return anything because the API user want zero rows
- nrows == n (for n <= number of rows in query) - return n rows
- nrows == n (for n > number of rows in query) - return number of rows in 
  query
- nrows < 0 - return a error because the API is used wrong

The raised issues about the memory leaks should now be fixed in mysql and 
postgresql. It makes now sense to call fetch_result after a "non select" 
query. In order to fetch rows you need some rows to work with. :-)

A behaviour like you drafted above would only cause confusion, IMHO.

Best regards,

Henning



More information about the Devel mailing list