Re: Re: cvs: php-src /ext/sybase_ct php_sybase_ct.c
| From: | Timm Friebe | Date: | Sat, 15 May 2004 14:30:13 +0000 |
| Subject: | Re: Re: cvs: php-src /ext/sybase_ct php_sybase_ct.c | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9859@lists.php.net to get a copy of this message | ||
On Fri, 2004-05-14 at 17:34, Alex Kiesel wrote:
> Hi Internals, hi Timm,
[...]
> This patch (committed with rev. 1.89 in ext/sybase_ct/php_sybase_ct.c)
> introduces a behaviour I consider broken:
>
> # select 2147483647
> becomes an int because Sybase automatically converts the input into
> an int (ints have precision 0 (or NULL).
>
> # select 2147483648
> becomes a float because Sybase convert this into a numeric(10,0),
> that is a numeric with precision 10. This numeric then will be
> converted into a float (because of the code in the second quote).
>
> This seems to be good, but this only works because the input is being
> autoconverted by Sybase into a suitable datatype. Autoconversion does,
> however, not apply to table columns (as they already have a type). Thus,
> the introduced decision (int or float depending on precision of type)
> applies to all rows of a result.
You're right, the decision needs to be made for each value while
retrieving the rows.
I've made a new patch and added a testcase, and, while doing so,
corrected an older testcase (LONG_MIN is -2147483648, not -2147483647:
thekid@friebes:~ > cat > long.c
#include <machine/limits.h>
int main(int argc, char* argv) {
printf("%d - %d\n", LONG_MIN, LONG_MAX);
}
thekid@friebes:~ > make long
cc -O -pipe long.c -o long
thekid@friebes:~ > ./long
-2147483648 - 2147483647
)
- Timm
Attachment: [text/x-patch] float-vs-int-php_sybase_ct.c.diff
Attachment: [text/x-patch] float-vs-int-php_sybase_ct.c.diff