Skip to Content.
Sympa Menu

freetds - RE: MS SQLServer 2000 and "for xml auto" command

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Brian Bruns" <camber AT ais.org>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: RE: MS SQLServer 2000 and "for xml auto" command
  • Date: Thu, 29 Aug 2002 12:08:00 -0400



What the hey, this is based on code that's a few days old, but it *should*
apply. In addition to this token.c change you need to add XSYBNTEXT to
the is_unicode macro in tds.h.in (a good patch for me is removing more
lines than i add ;-)

Brian

*** token.orig Thu Aug 29 11:48:55 2002
--- token.c Thu Aug 29 11:52:44 2002
***************
*** 691,696 ****
--- 691,698 ----
}

curcol->column_unicodedata = 0;
+ if (is_unicode(curcol->column_type))
+ curcol->column_unicodedata = 1;

switch(curcol->column_type) {
case XSYBVARBINARY:
***************
*** 700,715 ****
curcol->column_type=SYBBINARY;
break;
case XSYBNVARCHAR:
- curcol->column_type=SYBVARCHAR;
- curcol->column_unicodedata = 1;
- break;
case XSYBVARCHAR:
curcol->column_type=SYBVARCHAR;
break;
case XSYBNCHAR:
- curcol->column_type=SYBCHAR;
- curcol->column_unicodedata = 1;
- break;
case XSYBCHAR:
curcol->column_type=SYBCHAR;
break;
--- 702,711 ----

> Ok, I think I know what is going on. In tds7_process_result() there is a
> switch statement that sets curcol->column_unicodedata if the column type
> is a unicode capable datatype. ntext is missing from the list. I don't
> have time (nor am i somewhere convenient) to make a patch right now but we
> really should be calling is_unicode() on the datatype instead of having
> this int the switch statement, and then fixing it in the header, nice and
> clean.
>
> Brian
>
> > Brian gets the prize!
> >
> > Every other byte is a null! Which in turn throws off the normal print
> > out of the value. If I iterate through the buffer I get a result like:
> >
> >
> > Value: <
> > Value:
> > Value: t
> > Value:
> > Value: d
> > Value:
> > Value: s
> > Value:
> > Value: _
> > Value:
> > Value: t
> > Value:
> > Value: e
> > Value:
> > Value: s
> > Value:
> > Value: t
> > ...
> >
> > I'll try to run down where the unicode to ascii conversion happens and
> > see if I can pin point it.
> >
> > Thanks again,
> > chad
> >
> > Brian Bruns wrote:
> >
> > >Chad,
> > >
> > >Just a thought, it may not turn up anything but....
> > >
> > >in the unittest can you have it print buf[0], buf[1] etc... up to say 10
> > >or so? I'm wondering if something is going on with the unicode to ascii
> > >conversion and the second byte (buf[1]) is a null and thus appearing to
> > >be
> > >cut off when handling via C.
> > >
> > >Brian
> > >
> > >
> > >
> > >>I am using a snapshot from 8/22 - which, if I may say, is working quite
> > >>nicely for everything else I am doing.
> > >>
> > >>I have debugged the issue all the way to src/tds/read.c and the
> > >>tds_get_n function. I can see nothing wrong with the way the code copies
> > >>out the contents of tds->in_buf to the destination but yet I get just
> > >>the opening < for the result.
> > >>
> > >>I also thought perhaps I was fetching the results incorrectly so I
> > >>altered one of the unit tests in src/dblib/unittests (t0013.c) to use my
> > >>select and it has the same issue.
> > >>
> > >>If I can be of any help in getting this worked out please just let me
> > >>know.
> > >>
> > >>Thanks
> > >>chad
> > >>
> > >>Lowden, James K wrote:
> > >>
> > >>
> > >>
> > >>>>From: Chad Enney [mailto:Chad.Enney AT noaa.gov]
> > >>>>Sent: August 28, 2002 4:21 PM
> > >>>>
> > >>>>RedHat Linux 7.3 connecting to a MS SQLServer 2000 using TDS
> > >>>>protocol 7.0
> > >>>>
> > >>>>SELECT * FROM tds_test FOR XML AUTO;
> > >>>>
> > >>>>Everything looks fine but I only get back the very first character of
> > >>>>the returned result. I have turned on the tdsdump file and
> > >>>>can clearly
> > >>>>see the entire result being returned on the stack. The type is being
> > >>>>returned as a SYBNTEXT - and I can retrieve standard columns of this
> > >>>>type just fine.
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>Chad,
> > >>>
> > >>>Thanks for the PR; xml stuff is new turf.
> > >>>
> > >>>What version of FreeTDS are you using, or what's the date of your
> > >>>snapshot?
> > >>>
> > >>>--jkl




Archive powered by MHonArc 2.6.24.

Top of Page