[freetds] 0.64 crashes in PHP with NULL value TEXT type

L J Bayuk ljb220 at mindspring.com
Fri Jul 28 21:05:31 EDT 2006


On Fri, Jul 28, 2006 at 02:19:25PM -0400, Lowden, James K wrote:
> > ...
> > I built and tested FreeTDS-0.64 and it crashes PHP in one of my
> > tests.  The specific case is a TEXT type field (this is an unlimited
> > length VARCHAR) with value NULL. When I select a record with a NULL
> > text field, PHP crashes something like this:
> > ...
> 
> I tried two queries in sqsh.  A zero-length text field reports a length
> of 0; a NULL text field of -1.  
> ...
> I am using TDS 7.0, however, not 5.0 as with ASA.  Perhaps you could try
> my queries on your server and let me know?  

Thanks for the help (and the easier queries). I should have mentioned that
sqsh does not crash, only PHP. But TDSDUMP shows that sqsh is also getting
the odd results. And my results are different from yours. I have the full
logs, but they are long so here is what I hope is relevant. These are for
PHP - sqsh is the same here except it doesn't crash.

You: TDS 7.0 talking to ??? database
Me:  TDS 5.0 talking to Sybase ASA 9 database

First Query: SELECT CAST('' AS TEXT):
You:
> token.c:1863:tds_get_data: column 0, type 35, varint size 4
> token.c:1920:processing row.  column size is 0
> ct.c:1677:_ct_bind_data(): column_type: 35 column_len: 0

Me:
> token.c:1863:tds_get_data: column 0, type 35, varint size 4
> token.c:1920:processing row.  column size is 1 
> ct.c:1677:_ct_bind_data(): column_type: 35 column_len: 1

As you can see, my size for '' is 1, yours is 0. I thought my size included
the \0. For a 2-character string, my size is 3. Same for CHAR and VARCHAR.


Second Query: SELECT CAST(NULL as TEXT):  (PHP segfaults)
You:
> token.c:1863:tds_get_data: column 0, type 35, varint size 4
> token.c:1920:processing row.  column size is -1
> ct.c:1677:_ct_bind_data(): column_type: 35 column_len: -1

Me:
> token.c:1863:tds_get_data: column 0, type 35, varint size 4
> token.c:1920:processing row.  column size is 0 
> ct.c:1677:_ct_bind_data(): column_type: 35 column_len: 0

You got -1 for NULL, I got 0. But I get -1 for NULL in CHAR and VARCHAR.



More information about the FreeTDS mailing list