Thread: binary format of array stored as text
I have an old table with a column specified as integer[]. The data within this column was stored as text ala {1,2,3,…} yada yada. I have an application where I am reading all the columns from a row in this table in binary format. Does anybody know how I can recast/reshape this binary data back into an array of integers?
The array in text format is:
{0,3,3,18,19,19,35,35}
The array in binary format is:
0000 0001 0000 0000 0000 0017 0000 0008
0000 0001 0000 0004 0000 0000 0000 0004
0000 0003 0000 0004 0000 0003 0000 0004
0000 0012 0000 0004 0000 0013 0000 0004
0000 0013 0000 0004 0000 0023 0000 0004
0000 0023
I can make some assumptions to interpet “0000 0004 0000 0023” as a 32-bit length followed by length bytes (length = 4, data = 0x23 = 35), but I have no clue how to interpret the leading 20 bytes of this data.
I appreciate any help I can get.
Thanks,
Dave Huber
This electronic mail message is intended exclusively for the individual(s) or entity to which it is addressed. This message, together with any attachment, is confidential and may contain privileged information. Any unauthorized review, use, printing, retaining, copying, disclosure or distribution is strictly prohibited. If you have received this message in error, please immediately advise the sender by reply email message to the sender and delete all copies of this message.
THIS E-MAIL IS NOT AN OFFER OR ACCEPTANCE: Notwithstanding the Uniform Electronic Transactions Act or any other law of similar import, absent an express statement to the contrary contained in this e-mail, neither this e-mail nor any attachments are an offer or acceptance to enter into a contract, and are not intended to bind the sender, LeTourneau Technologies, Inc., or any of its subsidiaries, affiliates, or any other person or entity.
WARNING: Although the company has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.
On Wed, Sep 2, 2009 at 3:50 PM, Dave Huber<DHuber@letourneautechnologies.com> wrote: > I have an old table with a column specified as integer[]. The data within > this column was stored as text ala {1,2,3,…} yada yada. I have an > application where I am reading all the columns from a row in this table in > binary format. Does anybody know how I can recast/reshape this binary data > back into an array of integers? check out our libpqtypes library: http://libpqtypes.esilo.com/ It pulls all data as binary and allows you to access array elements, and you can write data the same way. PostgreSQL binary formats are more complicated than you think: there is dimension information, etc. in there. (that said, sending int[] as binary is much faster). merlin