dbTalk Databases Forums  

binary bytea

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss binary bytea in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Kitzinger ARA/SWD
 
Posts: n/a

Default binary bytea - 04-07-2004 , 05:45 PM






I'm confused. I have a bytea column that should be binary format (right?), yet PQfformat() says it is NOT binary (I did an insert as such: INSERT INTO tablename values (..., '\\001\\002\\000'); ). I also tried: INSERT INTO tablename values (..., '\\001\\002\\000'::bytea); .

Furthermore, my client code receives via PQgetvalue() a backslashed octet string which needs to be converted back into binary data via PQunescapeBytea() to get the binary contents, yet the documentation under PQunescapeBytea() (section 27.3.2) says its not needed when receiving binary data (implying there is a way to get binary data). How do I get/request binary data instead of text strings. My client code is connecting via TCP/IP if that makes a difference. I also noted in the documentation some sample client code that converted an int4 column to binary via: ntohl() also implying it was in binary format to begin with.

What's the secret? I would love to deal directly with binary data to avoid repetitious conversions to/from strings.

Thanks in advance for any advise!

--David Kitzinger


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: binary bytea - 04-09-2004 , 10:15 PM






David Kitzinger ARA/SWD <David.Kitzinger (AT) ara (DOT) com> writes:
Quote:
I'm confused. I have a bytea column that should be binary format
(right?), yet PQfformat() says it is NOT binary
The column datatype has nothing to do with whether the data is presented
in binary or textual format. The way you determine that is by making a
query in the right way. See for instance the resultFormat parameter of
PQexecParams.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #3  
Old   
M. Bastin
 
Posts: n/a

Default Re: binary bytea - 04-10-2004 , 04:28 AM



Quote:
How do I get/request binary data instead of text strings.
You can do this with FETCH. Look it up in the docs for the full picture.

Marc

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.