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: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] dbbind, dbnullbind issues
  • Date: Tue, 15 Jun 2004 16:16:12 +0100

OK Guys, here goes....

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

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

I've written a program which will select the column 6 times and bind it in
various different ways to different host variables.
In the first three cases, all the host variables are char[21] and have been
initialised with 20 '@' characters
In the last case they are declared as DBVARYCHAR ( a structure with an int
length and a char[256] string in it )

here's some output from the Sybase version.

bindtype = NTBSTRINGBIND bindlen = 12 data = >1234567890< ind = 0
bindtype = NTBSTRINGBIND bindlen = 11 data = >1234567890< ind = 0
bindtype = NTBSTRINGBIND bindlen = 10 data = >123456789< ind = 0
bindtype = NTBSTRINGBIND bindlen = 5 data = >1234< ind = 10
bindtype = NTBSTRINGBIND bindlen = 0 data = >1234567890< ind = 0
bindtype = NTBSTRINGBIND bindlen = -1 data = >1234567890< ind = 10

bindtype = STRINGBIND bindlen = 12 data = >1234567890 < ind = 0
bindtype = STRINGBIND bindlen = 11 data = >1234567890< ind = 0
bindtype = STRINGBIND bindlen = 10 data = >123456789< ind = 0
bindtype = STRINGBIND bindlen = 5 data = >1234< ind = 10
bindtype = STRINGBIND bindlen = 0 data = >1234567890< ind = 10
bindtype = STRINGBIND bindlen = -1 data = >1234567890< ind = 10

bindtype = CHARBIND bindlen = 12 data = >1234567890 @@@@@@@@< ind =
0
bindtype = CHARBIND bindlen = 11 data = >1234567890 @@@@@@@@@< ind =
0
bindtype = CHARBIND bindlen = 10 data = >1234567890@@@@@@@@@@< ind =
0
bindtype = CHARBIND bindlen = 5 data = >12345@@@@@@@@@@@@@@@< ind =
10
bindtype = CHARBIND bindlen = 0 data = >1234567890@@@@@@@@@@< ind =
0
bindtype = CHARBIND bindlen = -1 data = >1234567890@@@@@@@@@@< ind =
0

bindtype = VARYCHARBIND bindlen = 12 data = >1234567890@@@@@@@@@@< len =
10 ind = 0
bindtype = VARYCHARBIND bindlen = 11 data = >1234567890@@@@@@@@@@< len =
10 ind = 0
bindtype = VARYCHARBIND bindlen = 10 data = >1234567890@@@@@@@@@@< len =
10 ind = 0
bindtype = VARYCHARBIND bindlen = 5 data = >12345@@@@@@@@@@@@@@@< len =
5 ind = 10
bindtype = VARYCHARBIND bindlen = 0 data = >1234567890@@@@@@@@@@< len =
10 ind = 0
bindtype = VARYCHARBIND bindlen = -1 data = >1234567890@@@@@@@@@@< len =
10 ind = 0

Looking at how the indicator variables have been set shows a few things:

1) NTBSTRINGBIND and STRINGBIND are inconsistent in their handling of
bindlen = 0.
2) NTBSTRINGBIND and STRINGBIND both fail to report the truncation when
bindlen = 10
3) only CHARBIND and VARYCHARBIND seem to behave properly, as I read the
documentation.

It all makes a little more sense when you spot the N.B. in the
documentation, which states:

"only CHARBIND and VARYCHARBIND can detect truncation of character strings."

This would be better put:

"only CHARBIND and VARYCHARBIND accurately detect and report truncation of
character strings"

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.


Bill


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

==============================================================================





Archive powered by MHonArc 2.6.24.

Top of Page