#24796 [NoF->Opn]: Error in handling INT64 type value

From: Date: Thu, 31 Jul 2003 16:10:41 +0000
Subject: #24796 [NoF->Opn]: Error in handling INT64 type value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-45115@lists.php.net to get a copy of this message
ID: 24796 User updated by: acdweb at yahoo dot com Reported By: acdweb at yahoo dot com -Status: No Feedback +Status: Open Bug Type: InterBase related Operating System: Redhat Linux 9.0 PHP Version: 4.3.2 New Comment: To: sniper@php.net This problem still exist in latest PHP. The only reason that "I" no longer experience the problem is that "I fixed my source" and compiled myself. I'm reporting this bug to help fellow Phpers. Previous Comments: ------------------------------------------------------------------------ [2003-07-29 07:26:09] sniper@php.net No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. ------------------------------------------------------------------------ [2003-07-24 14:25:11] sniper@php.net Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip The code has changed quite a lot, please give it a go. also, if the problem persists, can you please give us a complete test script(s) to reproduce this problem? (with db creation script too) ------------------------------------------------------------------------ [2003-07-24 11:42:51] acdweb at yahoo dot com Description: ------------ Hello! PROBLEM: value "0" is replaced with "" when var type is INT64 REASON: a bug when casting INT64 to STRING FILENAME: interbase.c FUNCTION: static int _php_ibase_var_pval() Original Code: #ifdef SQL_INT64 case SQL_INT64: val->type = IS_STRING; if (scale) { int j, f = 1; double number = (double) ((ISC_INT64) (*((ISC_INT64 *)data))); char dt[20]; for (j = 0; j < -scale; j++) { f *= 10; } sprintf(dt, "%%0.%df", -scale); val->value.str.len = sprintf (string_data, dt, number/f ); } else { val->value.str.len =sprintf (string_data, "%.0" ISC_INT64_FORMAT "d", (ISC_INT64) *(ISC_INT64 *) data); } val->value.str.val = estrdup(string_data); break; #endif Fixed Code: #ifdef SQL_INT64 case SQL_INT64: val->type = IS_STRING; if (scale) { int j, f = 1; double number = (double) ((ISC_INT64) (*((ISC_INT64 *)data))); char dt[20]; for (j = 0; j < -scale; j++) { f *= 10; } sprintf(dt, "%%0.%df", -scale); val->value.str.len = sprintf (string_data, dt, number/f ); } else { if ((ISC_INT64) *(ISC_INT64 *) data == 0) { val->value.str.len =sprintf (string_data, "0"); } else { val->value.str.len =sprintf (string_data, "%.0" ISC_INT64_FORMAT "d", (ISC_INT64) *(ISC_INT64 *) data); } } val->value.str.val = estrdup(string_data); break; #endif Thank you for your work! Justin Kang Reproduce code: --------------- print_r($result) Expected result: ---------------- Array ( [ID] => 3 [BLEED] => 0 [DESCRIPTION] => Front Side ) Actual result: -------------- Array ( [ID] => 3 [BLEED] => [DESCRIPTION] => Front Side ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24796&edit=1

« previous php.bugs (#45115) next »