From: Roger G. <ro...@co...> - 2003-05-07 10:37:01
|
On Wed, May 07, 2003 at 01:01:48PM +0300, Vladimir Tcvigyn wrote: > Hello, Roger Gammans >=20 >=20 > > > +// if (resultSet) > > > + releaseResultSet(); > > >=3D20 > > > if (!statement->getMoreResults()) > > > return NULL; > > > > I'm not convinced about this hunk, I seem to recall you can force > > the a double free without it, why did you need this? > > > 1) > void OdbcStatement::releaseResultSet() > { > if (resultSet) <------------ !!!!!!!! >[snip] Ahh, Ok. , you are right we don't need to check this in two places. > > > @@ -623,13 +623,14 @@ > > >=3D20 > > > var->sqlscale =3D 0; > > > var->sqldata =3D (char*) &value->data; > > > - var->sqlind =3D NULL; > > > + *var->sqlind =3D 0; > > >=3D20 > > > switch (value->type) > > > { > > > case Null: > > > - var->sqltype =3D SQL_LONG; > > > - var->sqlind =3D &sqlNull; > > > + var->sqltype |=3D 1; > > > + *var->sqlind =3D sqlNull; > > > + memset (var->sqldata, 0, var->sqllen); > > > break; > > >=3D20 > > > case String: > > >=3D20 > > > > The changes to sqlind in this hunk are wrong as sqlind is never > > allcoated, it quite ssafe for it to share sqlNull as a single int > > instance for all null value, which the original implementation did, > > howver I do agree with your sqtype change and I had previously posted= =3D20 > > an equivalent. The chnages to sqltype should be enough to get Nulls > > working. > > > 1) SQLDA.CPP > void Sqlda::setBlob(XSQLVAR * var, Value * value, IscConnection *connecti= on) > { > if (value->type =3D=3D Null) > { > var->sqltype |=3D 1; <-------------!!!!!!!!! > *var->sqlind =3D -1;<-------------!!!!!!!!! > memset (var->sqldata, 0, var->sqllen);<-------------!!!!!!!!! > return; > } >=20 > 2) Help file ApiGuide.pdf - page 88 > short *sqlind >=20 > On input, specifies the address of an indicator variable; set by an > application; on output, specifies the address of column indicator value f= or > a select-list item following a FETCH > A value of 0 indicates that the column is not NULL; a value of -1 indicat= es > ^^^^^^ > the column is NULL; set by InterBase >=20 >=20 > 3) Do not trust - check up! Um, I've traced this bug trough the server code as well.... All of the example code iin the apiguide suggests that for column types specificied without the NULL bit it is unenscasary to provide storeg for sqlind. For input values its ok,=20 > No work! Try Excpection > var->sqltype =3D SQL_LONG; > var->sqlind =3D &sqlNull; Yes, but that's becuase the sqltype parameter is wrong, joust changing that one line :- - var->sqltype =3D SQL_LONG; + var->sqltype |=3D 1; Should be sufficent to fix it, whats more as I said no where is memory for sqlind allocated, and note that there is a declartion 'short sqlNill=3D-1;' so that this statically allocates memory in the which can be shared , so if you do var->sqlind=3D&sqlNull , you achieve the same thing, it meets the API guides requirements, there is no need=20 to sepecific a pointer when for non-null data, this is in the guide, and it examples. The follow patch also works, I know becasue I use it!. diff -u -r1.5 Sqlda.cpp --- IscDbc/Sqlda.cpp 25 Nov 2002 18:58:28 -0000 1.5 +++ IscDbc/Sqlda.cpp 7 May 2003 10:32:44 -0000 @@ -628,7 +641,7 @@ switch (value->type) { case Null: - var->sqltype =3D SQL_LONG; + var->sqltype =3D (var->sqltype & ~1) +1;=20 var->sqlind =3D &sqlNull; break; =20 It has the value of being simpler,quicker (no memset) and lower memory=20 usage, while till being correct. =20 Admittedly your sqltype line is easier to understand though. =20 > Work! >=20 > var->sqltype |=3D 1; > *var->sqlind =3D sqlNull; > memset (var->sqldata, 0, var->sqllen); >=20 > Your opinion? Yes but your lucky not to get a gpf/segv since sqlind hasn't been initialised, al;so the memset is unecessary since the sever ingores the data segment if (*sqlind)=3D=3D-1 . Lets not put in things to slow down performance if they're not needed. TTFN --=20 Roger. Home| http://www.sandman.uklinux.net/ Master of Peng Shui. (Ancient oriental art of Penguin Arranging) GPG Key FPR: CFF1 F383 F854 4E6A 918D 5CFF A90D E73B 88DE 0B3E Work|Independent Systems Consultant | http://www.firstdatabase.co.uk/ |