Re: Pointers in custom types - Mailing list pgsql-general

From Tom Lane
Subject Re: Pointers in custom types
Date
Msg-id 27426.1235238295@sss.pgh.pa.us
Whole thread Raw
In response to Pointers in custom types  (Will Harrower <wjh105@doc.ic.ac.uk>)
Responses Re: Pointers in custom types
List pgsql-general
Will Harrower <wjh105@doc.ic.ac.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Fixing invalid owners on pg_toast tables in 8.3.5
Next
From: Will Harrower
Date:
Subject: Re: Pointers in custom types