Skip to Content.
Sympa Menu

freetds - Re: killer query

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: ZIGLIO Frediano <Frediano.Ziglio AT vodafoneomnitel.it>
  • To: "'TDS Development Group'" <freetds AT franklin.metalab.unc.edu>
  • Subject: Re: killer query
  • Date: Wed, 26 Jun 2002 14:16:18 +0200


>
> Bill,
>
> TDS 7 is little endian only, so there would be no swapping of
> bytes. True
> this is only valid for direct manipulation of the TDS_UNIQUE
> structure.
> The way to deal with this would be to implement the byte swap
> code for
> TDS_UNIQUE in tds_swap_datatype(). Given that SYBUNIQUE -> SYBCHAR
> (currenly) relies on the byte order being little endian, does
> any of this
> matter? If anyone can show me any code that directly manipulates
> SYBUNIQUE then I think a patch is appropriate, otherwise
> let's let it be.
>
> Given that SYBUNIQUE is not part of the original spec no
> programs should
> be doing anything with it other than binding as char. But
> again, if there
> is any reason to treat TDS_UNIQUE as anything other than
> opaque, we should
> fix it.
>
> Brian
>
Watching code more deeply bytes are swapped on tds_swap_datatype() for big
endian machines, so copy beetwen struct should work fine (is same packed
data). But in tds_convert_unique we convert uuid to string using always a
bigendian representation

(from src/tds/convert.c)
any.c = malloc(37);

sprintf(any.c,"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%
02X%02X",
buf[0], buf[1], buf[2], buf[3],
buf[4], buf[5],
buf[6], buf[7],
buf[8], buf[9],
buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);

Executing this code (from Sql query analizer)

create table #temp ( uuid uniqueidentifier )
insert into #temp values('01020304-0506-0708-0910-111213141516')
select uuid from #temp

Data are returned (on socket stream) in this order
04 03 02 01 06 05 08 07 09 10 11 12 13 14 15 16

freddy77

=================================
"STRICTLY PERSONAL AND CONFIDENTIAL

This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."

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




Archive powered by MHonArc 2.6.24.

Top of Page