User defined types and storage variance - Mailing list pgsql-general

From Dave Trombley
Subject User defined types and storage variance
Date
Msg-id 3C44B774.4040605@bumba.net
Whole thread Raw
Responses Re: User defined types and storage variance  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
    Is it correct of me to assume that the concrete storage of a user
defined type, defined in C, must not contain any references to
structures allocated per-object?  The documentation does not explicitly
specify this, but there is a lack of a callback in the CREATE TYPE
command to be invoked when the database type instance is no longer
referenced, so I see no way of freeing such storage if it were
allocated.  Also, I can't see how the backend would know how to follow
such a reference without some indication that it was a reference, and
also the storage length of the structure.  So this seems plain.

    What I'd like to do is implement a structure whose concrete storage
length may change when it is operated on (a sparse matrix), but since
realloc() on most systems may change the memory location of the pointer,
I see no way of doing this given the above restriction.  Perhaps it
would be possible to have a function somehow tell the back end to
associate the OID of the type instance it is operating on with a
different concrete storage block?

    More generally, exactly how /does/ concrete storage allocation and
deallocation behave for user-defined types?


    -David J. Trombley
     <dtrom@bumba.net>


pgsql-general by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Problem whith table views.
Next
From: Tom Lane
Date:
Subject: Re: User defined types and storage variance