From: delta_v at mail dot ru
Operating system: Windows 2000 Prof
PHP version: 5.1.4
PHP Bug Type: SQLite related
Bug description: user aggregate function on empty select result
Description:
------------
user aggregate function on empty select result
Apache crach
Reproduce code:
---------------
function actstep(&$context,$tau,$val) {
if ($conext[0]<$tau) { $conext[0]=$tau; $context[1]=$val; }
}
function actfin(&$context) {
return $context[1];
}
$f = 'tmp.sqlt';
unlink($f);
$h = sqlite_open($f);
sqlite_exec($h,"CREATE TABLE lnk(obj,atr,tau,val)");
sqlite_exec($h,"INSERT INTO lnk VALUES(1,1,2,5)");
sqlite_exec($h,"INSERT INTO lnk VALUES(1,1,5,10)");
sqlite_create_aggregate($h,'actual','actstep','actfin');
// This work:
$r1 = sqlite_array_query($h,"SELECT actual(tau,val) FROM lnk WHERE obj=1
AND atr=1 AND tau<=10",SQLITE_NUM);
// When empty result set Apache crach:
$r2 = sqlite_array_query($h,"SELECT actual(tau,val) FROM lnk WHERE obj=2
AND atr=1 AND tau<=10",SQLITE_NUM);
var_dump($r1);
var_dump($r2);
Expected result:
----------------
array(1) { [0]=> array(1) { [0]=> string(2) "10" } }
null
Actual result:
--------------
Crach
--
Edit bug report at http://bugs.php.net/?id=38156&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=38156&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=38156&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=38156&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38156&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=38156&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38156&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38156&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38156&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38156&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38156&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=38156&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=38156&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38156&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38156&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38156&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38156&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38156&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38156&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38156&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38156&r=mysqlcfg