Re: Pointers in custom types

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

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Will Harrower 2009-02-21 17:49:25 Re: Pointers in custom types
Previous Message Tom Lane 2009-02-21 17:30:50 Re: Fixing invalid owners on pg_toast tables in 8.3.5