From: | "Frost, Mr(dot) Michael (contractor)" <frost(at)nrlmry(dot)navy(dot)mil> |
---|---|
To: | <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | PQescapeBytea & PQunescapeBytea |
Date: | 2005-05-03 20:51:53 |
Message-ID: | 5188F15076BC7A4DBB705747602058C11AAB88@mailhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hi. I am running 7.4.6 of postgres. I have some data that I desire to
store as bytea in postgres. The data is an array of floats. I cast the
array of floats to a unsigned char and call PQescapeBytea to prepare the
data for ingest. I insert it into the database, and then extract it
back out. I then call PQunescapeBytea and cast it back to float to
return it to it's original.
However, I am probably doing something incorrect, since the before /
after data is not the same.
So, I eliminate the ingest into the database, and basically just called
the PQescapeBytea & PQunescapeBytea and I get different results.
In my example, I fill an array of 10 floats with values from 0.0 to 9.0.
I then cast this to unsigned char. I then call PQescapeBytea.
for ( i = 0; i < 10; i++ )
prsData = ( float ) i;
pData = ( unsigned char * ) prsData;
pEscapedData = PQescapeBytea ( pData, 40, &newSize );
// newSize comes back to be 161.
Then I call PQunescapeBytea with pEscapedData. This returns a newSize
that is different from the original.
pUnescapedData = PQunescapeBytea ( pEscapedData, &newSize );
// newSize comes back to be 130, but I expected it to be 40.
Any insight as to what I am doing incorrectly.?
Thanks,
Michael Frost
Computer Sciences Corporation
Phone: 831-656-4723
Fax: 831-656-4769
Email: frost(at)nrlmry(dot)navy(dot)mil
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Hallgren | 2005-05-03 21:19:43 | Re: Deep integration of PostgreSQL with Apache |
Previous Message | Clay, Bruce | 2005-05-03 18:28:51 | ArcCatalog interface to PostgeSql question |