freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
RE: [freetds] Re: Inserting empty strings into MS SQL Server
- From: "Charles Bearden" <Charles.F.Bearden AT uth.tmc.edu>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>, <joe AT mail.paravisions.com>
- Cc:
- Subject: RE: [freetds] Re: Inserting empty strings into MS SQL Server
- Date: Mon, 9 Aug 2004 16:58:35 -0500
> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org [mailto:freetds-
> bounces AT lists.ibiblio.org] On Behalf Of Scott Johnson
> Sent: Monday, August 09, 2004 3:35 PM
>
> *This message was transferred with a trial version of CommuniGate(tm)
Pro*
> ahh ok, my mistake. Could have been an easy fix :)
Nice thought.
I googled on the error message "Length or precision specification 0 is
invalid" and found a bug[1] in Mono concerning the SqlClient component
throwing an exception with the same message when preparing a statement
in which a string or binary parameter value has a length of 0 (for
strings, an empty string). Judging from the TDSDUMP trace I included
previously, my INSERTs are also failing at the prepare stage
("Statement(s) could not be prepared").
A patch[2] was also posted in bugzilla and integrated into the code. I
don't know C or C++, so I can't necessarily identify the corresponding
part of the FreeTDS source code, but I did find what looks like a
similar part of the FreeTDS code (freetds-0.62.4/src/tds/convert.c,
starting at line 1598). In the definition of the tds_convert function
is the following assert statement (line 1621):
assert(srclen >= 0 && srclen <= 2147483647u);
However, the comments indicate that srclen is assumed to be greater than
0 (lines 1606f):
* This function do not handle NULL, srclen should be >0, if not
undefinited
* behaviour...
I also note that in freetds-0.62.4/src/tds/convert.c (line 702ff) is a
tds_submit_prepare function definition. I seem to see the
"s\0p\0_\0p\0r\0e\0p\0a\0r\0e" string at line 793 in the TDSDUMP output,
which makes me wonder if the error is raised after that point (in
tds7_put_query_params?).
I may have this all wrong, but I thought I'd at least make the effort to
look at the source code to see if I could help think this problem
through.
Thanks in advance for any further ideas,
Chuck
[1] http://bugzilla.ximian.com/show_bug.cgi?id=49856
[2] http://bugzilla.ximian.com/showattachment.cgi?attach_id=5668
> ----- Original Message -----
> From: "Joseph Geiser" <joe AT mail.paravisions.com>
> To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
> Sent: Monday, August 09, 2004 4:06 PM
> Subject: RE: [freetds] Re: Inserting empty strings into MS SQL Server
>
>
> > *This message was transferred with a trial version of
CommuniGate(tm)
> Pro*
> > Scott Johnson writes,
> >
> > > I might be incorrect in stating this, but doesn't ('') equate
> > > itself to
> > > one apostrophe for the purpose of inserting that?
> > >
> > >
> > > (1, 'foo', ' ', '', 'foo', 'foo', 'foo', 'foo', 'foo', 'foo',
'foo',
> > > 'foo',
> > > 'foo', 'foo', 'foo', 'foo', 'foo', 'foo', 'foo', 'foo', 'foo')
> >
> >
> > Not in an INSERT, where the only characters in a column are '' --
this
> > translates to "empty string" (not NULL). If the value had
characters
> and
> a
> > double-apostrophe (ie: 'O''Malley') - then it would be an escaped
> > apostrophe.
> >
> > HTH...
> >
> > Joe
> >
> > _______________________________________________
> > FreeTDS mailing list
> > FreeTDS AT lists.ibiblio.org
> > http://lists.ibiblio.org/mailman/listinfo/freetds
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
-
[freetds] Re: Inserting empty strings into MS SQL Server,
Charles Bearden, 08/09/2004
-
RE: [freetds] Re: Inserting empty strings into MS SQL Server,
Scott Johnson, 08/09/2004
-
RE: [freetds] Re: Inserting empty strings into MS SQL Server,
Joseph Geiser, 08/09/2004
- Re: [freetds] Re: Inserting empty strings into MS SQL Server, Scott Johnson, 08/09/2004
-
RE: [freetds] Re: Inserting empty strings into MS SQL Server,
Joseph Geiser, 08/09/2004
-
Re: [freetds] Re: Inserting empty strings into MS SQL Server,
James K. Lowden, 08/09/2004
- RE: [freetds] Re: Inserting empty strings into MS SQL Server, Joseph Geiser, 08/10/2004
- Re: [freetds] Re: Inserting empty strings into MS SQL Server, Frediano Ziglio, 08/10/2004
- <Possible follow-up(s)>
- RE: [freetds] Re: Inserting empty strings into MS SQL Server, Charles Bearden, 08/09/2004
- RE: [freetds] Re: Inserting empty strings into MS SQL Server, Charles Bearden, 08/10/2004
- RE: [freetds] Re: Inserting empty strings into MS SQL Server, Charles Bearden, 08/10/2004
- RE: [freetds] Re: Inserting empty strings into MS SQL Server, Charles Bearden, 08/10/2004
- RE: [freetds] Re: Inserting empty strings into MS SQL Server, Charles Bearden, 08/10/2004
-
RE: [freetds] Re: Inserting empty strings into MS SQL Server,
Scott Johnson, 08/09/2004
Archive powered by MHonArc 2.6.24.