Skip to Content.
Sympa Menu

freetds - RE: [freetds] what size indicator

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddyz77 AT tin.it>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] what size indicator
  • Date: Sat, 05 Jun 2004 10:11:45 +0200

Il ven, 2004-06-04 alle 23:16, Lowden, James K ha scritto:
> >
> > >
> > > 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.
>

libtds to not use these fields.

> 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.
>

Using grep like


grep -rw
'\(column_bindtype\|column_bindfmt\|column_bindlen\|column_nullbind\|column_varaddr\|column_lenbind\|column_textpos\|column_text_sqlgetdatapos\)'
*

you will found that ODBC use only column_text_sqlgetdatapos (not used by
dblib or ctlib)

freddy77






Archive powered by MHonArc 2.6.24.

Top of Page