Hi:
Attached are three patches for ext/sybase. The first two fix bugs. The
third adds a function, while at the same time removing a lot of
redundant code. In order:
php5_sybase-fetch_object.diff:
The sybase extension does not currently compile, since
sybase_fetch_object was never converted to ZE2's new object API.
This patch converts sybase_fetch_object, fixes three warnings, and
checks the return value of malloc() in the one place it's used.
Please apply this - ext/sybase is broken in PHP5 without it.
php_sybase-string-termination:
With --enable-debug turned on, both ZE1 and ZE2 emit warnings about
null-termination for each call to sybase_query. These warnings are
caused by php_sybase_get_column_content, which returns a zval whose
internal string is not null-terminated. The original logic which
terminated the string was #ifdef'ed out; this patch replaces it
with a greatly simplified version. Tested with FreeTDS 0.60 against
Microsoft SQL Server 2000; also applies cleanly to PHP4.
php5_sybase-fetch_assoc.diff:
Most of the other PHP database extensions have three ways for rows
to be fetched: fetch_row (numeric keys), fetch_assoc (string keys),
or fetch_array (both numeric and string keys). The ext/sybase
extension currently has no sybase_fetch_assoc function. This patch
adds sybase_fetch_assoc, while at the same time removing the
duplication between sybase_fetch_row and php_sybase_fetch_hash. The
result is a unified php_sybase_fetch_hash capable of fetching in
either of the three modes, and three userland functions which pass
through to it. (Depends: php5_sybase-fetch_object.diff)
If these look okay, please apply. If not, I'll gladly fix and resend -
just let me know.
Thanks a lot,
- Dave
dave@spoonguard.org
Hi:
| + /* Get rid of extra nulls */
| + while (res_length > 0 && res_buf[res_length] == '\0')
| + res_length--;
| +
| Z_STRVAL_P(result) = res_buf;
| + Z_STRLEN_P(result) = res_length+1;
| Z_TYPE_P(result) = IS_STRING;
Replying to myself. Though this is technically correct (since the case
of res_length == 0 is filtered out before this code runs), it's really
unclear. Sorry about that. I've attached an updated patch - this one
does the right-trimming in the same way as it's done elsewhere in
php_sybase_get_column_content.
Thanks,
- Dave
dave@spoonguard.org