Skip to Content.
Sympa Menu

freetds - Re: [freetds] dbbind, dbnullbind issues

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] dbbind, dbnullbind issues
  • Date: Wed, 16 Jun 2004 02:01:10 -0400

On Tue, 15 Jun 2004, "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
wrote:

> I think I've reached a kind of understanding of what is happening, by
> some extensive testing.

Thanks for doing this, Bill. Very thorough work.

> I've got a table with a single row and a single column - char(10) -
> with data '1234567890' in it...

I mean, really, you've been working too hard or something. That's the
most boring data imaginable.

I loaded your results into a database and found this:

[25] varley.FreeTDS.1> select count(*), bindlen, ind from bind_results
group by bindlen, ind order by bindlen, ind
[25] varley.FreeTDS.2> go
bindlen ind
----------- ------- ------
2 -1 0
2 -1 10
3 0 0
1 0 10
4 5 10
4 10 0
4 11 0
4 12 0

(8 rows affected)

By the book, bindlen (varlen) of -1 should never work. If we don't reject
it outright, we should treat it as 0, never mind what Sybase does. I
note, ahem, that bsqldb uses -1. So much for setting a good example.

varlen of 0 appears broken in the case of STRINGBIND:

[27] varley.FreeTDS.1> select * from bind_results where bindlen = 0 order
by len, ind, type
[27] varley.FreeTDS.2> go
type bindlen data len ind
-------------------- ------- ------------------------- ------ ------
CHARBIND 0 >1234567890@@@@@@@@@@< NULL 0
NTBSTRINGBIND 0 >1234567890< NULL 0
STRINGBIND 0 >1234567890< NULL 10
VARYCHARBIND 0 >1234567890@@@@@@@@@@< 10 0

The dbnullbind() indicator should be >0 only to indicate truncation.
Because a varlen of 0 passes no information about the buffer's size,
db-lib can't possibly know where to truncate the data, nor does it
truncate them.

IMO this is a case for "do it right and let 'em complain". Any
application relying on STRINGBIND's broken behavior is itself broken.

varlen of 5 seems fine. It puts lie to the dbnullbind() note "Detection
of character string truncation is implemented only for CHARBIND and
VARYCHARBIND."

varlen of 10 is interesting:

[28] varley.FreeTDS.1> select * from bind_results where bindlen = 10 order
by len, ind, type
[28] varley.FreeTDS.2> go
type bindlen data len ind
-------------------- ------- ------------------------- ------ ------
CHARBIND 10 >1234567890@@@@@@@@@@< NULL 0
NTBSTRINGBIND 10 >123456789< NULL 0
STRINGBIND 10 >123456789< NULL 0
VARYCHARBIND 10 >1234567890@@@@@@@@@@< 10 0

CHARBIND and VARYCHARBIND *could* report truncation, but in this case no
truncation occurs and is thus not reported.

> In the light of this, I'm not going to populate the indicator variables
> at all for NTBSTRINGBIND and STRINGBIND, as there seems to be no logic
> to the observable behaviour.

NTBSTRINGBIND and STRINGBIND should but don't report truncation (but the
note says that's not "implemented"). Here again, ISTM we can and should
report the truncation. There's no need to replicate Sybase's off-by-one
error. We'll only be making this case consistent with the varlen 5 case.


(I suppose one could argue the documentation is right even without the
note. Truncation is reported if the binding "did not specify any data
conversions". If tacking a NULL onto the data is "conversion", then
truncation won't be reported.... But you won't hear *me* making that
case.)

Two questions for you, if I may:

1. Does dbnullbind() at least report NULLs correctly?
2. Does dbanullbind() show similar inconsistencies?

Regards,

--jkl


> > -----Original Message-----
> > From: Lowden, James K [SMTP:LowdenJK AT bernstein.com]
> > Sent: 15 June 2004 15:13
> > To: FreeTDS Development Group
> > Subject: RE: [freetds] dbbind, dbnullbind issues
> >
> > > From: freetds-bounces AT lists.ibiblio.org
> > > [mailto:freetds-bounces AT lists.ibiblio.org]On Behalf Of
> > > Thompson, Bill D
> > >
> > > I've been wrestling with the features of dbbind and
> > > dbnullbind
> > ...
> > > I could do several things:
> > >
> > > 1) code our dblibrary funstions so that they behave as
> > > specified in the manual pages.
> > > 2) attempt to reflect the actual (but inconsistent) behaviour
> > > of the Sybase implementation
> > > 3) code to a different, but clearer and arguably more sensible,
> > > specification.
> >
> > Hi Bill,
> >
> > Can you cite an example where someone following the letter of the
> > documentation would build a non-working application when linking to
> > one of the vendors' libraries?
> >
> > In general, I'm sure you agree that adhering to the documents is best.
> > Bug-for-bug compatibility is useful in two cases:
> >
> > 1. Following the docs doesn't actually work.
> > 2. Binary compatibility.
> >
> > The first case is truly bad, and I don't know of any examples. The
> > second is a far-off goal; we'll cross that bridge when we come to it,
> > IMO.
> >
> > The other kind of not-of-the-docs behavior are things that work but
> > aren't documented to work, things like using varlen of -1 that you
> > found. I think it's fine to support them when it's convenient, and
> > deny them when not. Anyone who complains can fix his code or change
> > ours.
> >
> > Is that any help?
> >
> > --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.
> >
> >
> > _______________________________________________
> > FreeTDS mailing list
> > FreeTDS AT lists.ibiblio.org
> > http://lists.ibiblio.org/mailman/listinfo/freetds
>
> =======================================================================
> =======
>
> If you are not an intended recipient of this e-mail, please notify
> the sender, delete it and do not read, act upon, print, disclose,
> copy, retain or redistribute it.
>
> Click here for important additional terms relating to this e-mail.
> <http://www.ml.com/email_terms/>
>
> =======================================================================
> =======
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds




Archive powered by MHonArc 2.6.24.

Top of Page