Re: Variable length custom data types help

From: "Morgan Kita" <mkita(at)verseon(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Variable length custom data types help
Date: 2005-04-01 21:16:25
Message-ID: 08B420FF5BF7BC42A064212C2EB768801C1092@neutron.verseon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


Thank you for your response! That was quite enlightening.

Just to clarify in the example foo structure below where the first
member is the length, and then you say /*rest of structure here*/, by
that do you mean the individual data members of the structure that will
be in my array of strucs? I guess it can't be a pointer to the array as
you said postgres will not know that you are storing pointers. If so
that means you have a bit of wasted overhead right? I think I will just
try creating the pointer as void*, set the first 4 bytes to the length,
and then fill in the rest.

Seriously, that was an extremely helpful post!

Thanks,
Morgan

-----Original Message-----
From: Michael Fuhr [mailto:mike(at)fuhr(dot)org]
Sent: Thursday, March 31, 2005 11:17 PM
To: Morgan Kita
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] Variable length custom data types help

The usual way is to create a structure:

typedef struct foo {
int32 total_length;
/* rest of structure here */
} foo;

What follows the length is irrelevant to PostgreSQL, so define it
however makes sense in your code. Just make sure that all data is
in a contiguous chunk of memory that begins with the 4-byte length
(don't embed pointers in the data, because PostgreSQL won't know
anything about them).

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Walker, Jed S 2005-04-01 21:52:20 plpgsql question - simple I would have thought
Previous Message Ennio-Sr 2005-04-01 18:36:35 Re: how to ignore accents?