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@nrlmry.navy.mil