Re: Pointers in custom types

From: Will Harrower <wjh105(at)doc(dot)ic(dot)ac(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Pointers in custom types
Date: 2009-02-21 17:49:25
Message-ID: 49A03EA5.1090805@doc.ic.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Will Harrower <wjh105(at)doc(dot)ic(dot)ac(dot)uk> writes:
>
>> I'm writing a custom type in C that needs to manage two byte arrays
>> (among other things). I have attempted to implement this using something
>> similar to the following struct (along with corresponding input and
>> output functions):
>>
>
>
>> typedef struct example {
>> bytea* first;
>> bytea* second;
>> } example;
>>
>
> You can't do that; the value of a datatype has to be a single chunk of
> memory, and it has to be independent of exactly where it's stored
> because it will get copied around without modification.
>
> regards, tom lane
>

Ok, that makes sense, thanks. Guess I'll stick to a bytea and an extra
index.

Cheers,
Will.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Mayer 2009-02-21 23:02:55 Re: where to divide application and database
Previous Message Tom Lane 2009-02-21 17:44:55 Re: Pointers in custom types