Subject: How to manipulate binary data in postgres?

From: lmr <[email-masked]>
Date: Sun, 17 Apr 1994 23:33:36 -0400 (EDT)

Greeting!

I have several questions about manipulating binary data in postgres.
Please help me !

Any documentations, sample code and hints are welcomed.

(1) For the circle example in The Postgres user manual (page16),
the insertion is done as:

append tutorial (a="(1.0, 1.0, 10.0)"::circle)\g

I have no problem with this. I am not sure how we do this in a
C program with a pointer. Specifically, suppose

char *cir_ptr;
....

strcpy(cir_ptr, "(1.0, 1.0, 10.0)");

Can we do

PQexec("append tutorial (a=cir_ptr::circle");  //?
                           ^^^^^^^
This example is not necessary but my binary data is not printable.
I have to use pointer to address the memory location. If not,
which is the correct way?

(2) All I want is to do something like (in C program)

define type my_bin
(internallength=variable,
input=my_bin_in, output=my_bin_out)\g

create my_class(bin_data=my_bin)\g

char* my_bin_ptr;

/* fill data*/
 insert data from my_bin_ptr and be able to retreve data into a
specified memory location. I don't see how to do this part.

Many thanks!
-- 
Liming Ren                       |  (614) 292-8989                   |  
Dept. of Mathematics             |  231 West 18th Avenue
The Ohio State University        |  Columbus, Ohio43210