New types in binary ?

From: Franck Martin <Franck(at)sopac(dot)org(dot)fj>
To: pgsql-general(at)postgresql(dot)org
Cc: "'fmaps-devel(at)lists(dot)sourceforge(dot)net'" <fmaps-devel(at)lists(dot)sourceforge(dot)net>
Subject: New types in binary ?
Date: 2000-06-26 05:05:14
Message-ID: F12ECEA0435AD211B5280008C7ACBC857FEC43@BIGIRON
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

We are developping a GIS system using PG as database.

We could create multiple geographic type in PG: point, line, polygon,... but
we would like to try something else.

We want to use this structure in creating a new PG type (extending PG type
in C)

typedef struct {
int4 size; /* for postgresql and us */
int4 type; /* The type of object NONE, POINT, etc. */
float8 bound[2][3]; /* bounding box -- min(x,y,z) max(x,y,z) */
char data[1]; /* Resizable variable type data */
} geoobj;

The geobj->data would contain the binary representation of various
structures:

typedef struct {
int4 type=1;
float x,y,z
} point

typedef struct {
int4 type=2;
float x1,y1,z1,x2,y2,z2;
} line

and so on...

We could write functions that will convert the various structures into an
ascii stream for display in PG:

select geoobj from table
"POINT [x,y,z]" , "LINE [x1,y1,z1][x2,y2,z2]"

But we would like also the data pushed in pure binary. We could use a
function to ensure we want the binary value of the type

Select XDR(geoobj) from table
<binarystuff>

We will then take the binary stuff stored in a char and we will cast it to
the right structure. Do you think it will work and PG will not jump to the
roof because of binary stream output as a char* ?

BTW it will create a varbinary type that is waiting to be toasted.

Cheers.

Franck Martin
Database Development Officer
SOPAC South Pacific Applied Geoscience Commission
Fiji
E-mail: franck(at)sopac(dot)org(dot)fj <mailto:franck(at)sopac(dot)org(dot)fj>
Web site: http://www.sopac.org.fj/ <http://www.sopac.org.fj/>

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Doré 2000-06-26 10:35:11 2 phase commit abilities
Previous Message Thomas Lockhart 2000-06-26 04:02:48 Re: SQL INSERT bug with 6.5.3 and 7.0.2