[freetds] what size indicator

Lowden, James K LowdenJK at bernstein.com
Fri Jun 4 17:16:35 EDT 2004


> -----Original Message-----
> From: freetds-bounces at lists.ibiblio.org
> [mailto:freetds-bounces at lists.ibiblio.org]On Behalf Of 
> ZIGLIO, Frediano, VF-IT
> Sent: June 4, 2004 8:51 AM
> > 
> > typedef struct tds_column
> > {
> > ...
> > 	TDS_SMALLINT *column_nullbind;
> > ...
> > } TDSCOLUMN;
> > 
> > blk_bind(CS_BLKDESC * blkdesc, CS_INT item, CS_DATAFMT * 
> > datafmt, CS_VOID
> > * buffer, CS_INT * datalen, CS_SMALLINT * indicator)
> > 
> > dbnullbind(DBPROCESS * dbproc, int column, DBINT * indicator)
> >                                            ^^^^^
> 
> Last Bill patch change the pointer from TDS_CHAR* to TDS_INT *.
> 
> >From include/tds.h
> 
...
> These fields are only used by client libraries (not libTDS) so every
> library should use as they like. Perhaps an union like
> 
> 	union {
> 		struct {
> 			...
> 		} db;
> 		struct {
> 			...
> 		} ct;
> 	} lib;
> would be better ??

I don't think it's necessary.  AFAIK:

1.  db-lib expects the caller to provide a DBINT buffer.  
2.  ct-lib expects the caller to provide a CS_SMALLINT buffer.  

I think what Bill did is basically right.  ct-lib and libtds use a 16-bit buffer, provided by the caller.  The db-lib API requires the user to provide a 32-bit buffer that libtds will treat as a 16-bit int.  

The db-lib caller, however, will examine his 32-bit buffer as a 32-bit int.  In buffer_transfer_bound_data(), I think we all we have to do is treat the nullbind indicator thus:  

	if (curcol->column_nullbind) {
		if (tds_get_null(resinfo->current_row, i)) {
			*(DBINT*)(curcol->column_nullbind) = -1;
		} else {
			*(DBINT*)(curcol->column_nullbind) = 0;
		}
	}

(N.B.  There's missing logic here.  Per the docs, the nullbind indicator should hold a positive value representing  "The full length of column's data, in bytes, if column was bound to a program variable through dbbind, the binding did not specify any data conversions, and the bound data was truncated because the program variable was too small to hold data for column."  Whew.  I wonder what exactly "did not specify any data conversions" means?  srctype==desttype?)

Tell me if that looks good to you, and what happens on the ODBC side.  

--jkl










-----------------------------------------
The information contained in this transmission may contain privileged and confidential information and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message. Please note that we do not accept account orders and/or instructions by e-mail, and therefore will not be responsible for carrying out such orders and/or instructions.
If you, as the intended recipient of this message, the purpose of which is to inform and update our clients, prospects and consultants of developments relating to our services and products, would not like to receive further e-mail correspondence from the sender, please "reply" to the sender indicating your wishes.  In the U.S.: 1345 Avenue of the Americas, New York, NY 10105.





More information about the FreeTDS mailing list