agora inbox for postgres@postgres.berkeley.edu
help / color / mirror / Atom feedFrom: Paul M. Aoki <aoki@postgres.Berkeley.EDU>
To: Bruce Taneja. <aataneja@cs.mtu.edu>
Cc: postgres@postgres.Berkeley.EDU
Subject: Re: complex data types ..
Date: Wed, 25 May 94 22:07:50 -0700
Message-ID: <199405260507.WAA10327@faerie.CS.Berkeley.EDU> (raw)
In-Reply-To: <9405260428.AA02346@cs.mtu.edu>
aataneja@cs.mtu.edu (Bruce Taneja.) writes:
> /* *** now how in the world do I call the circle_in function (parser) here
> and let it parse the rest of the "(3.0, 1.1, 2.1)" from above append ..
you could call circle_in. the existing adt code is in src/utils/adt.
circle_in will return a piece of palloc'd memory (as should your
input function). using a standard input function as a parser
means that at some point you would have to copy the returned
structure into your final structure (the one returned by
pyramid_in) so that it's all contiguous. you would have to pfree
the thing returned by circle_in, too.
if you have more complex, variable-length data types, you could
do something like assemble a recursive pointer-based structure
and then flatten it out at the end. that's if you really, really
want to use input functions. if you use slightly-hacked variants
that write into caller-provided buffers (code that you could
actually re-use in the input functions) you could do something
cleaner.
> Q.2 does some body know at how many nested levels of complex data types
> does postgres becomes unstable ... ?????
> Q.3 Can we use nested structs within a single new-data.c file (like circle.c
all postgres wants to know is that an adt is
- one contiguous hunk of memory (ie contains no pointers)
- either by-value, by-ref/fixed-length or by-ref/variable-length
- contained in palloc'd memory
internally, it treats by-ref adts as blobs. once in internal (core)
format, postgres doesn't do anything funny to it -- the only operations
it does on it are (1) copy it (eg onto disk pages) and (2) apply
whatever functions you have written for that adt.
so nesting of c structures shouldn't matter (given the above). after
all, only the c compiler ever parses your structure definitions. if
there are problems they probably lie in the input functions themselves
(not calling palloc, pfree'ing the wrong thing, returning the wrong
thing, etc.).
--
Paul M. Aoki | CS Div., Dept. of EECS, UCB | aoki@postgres.Berkeley.EDU
| Berkeley, CA 94720 | ...!uunet!ucbvax!aoki
==============================================================================
To add/remove yourself to/from the POSTGRES mailing list: send mail with
the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"
If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
a human will deal with it. DO NOT post to the "postgres" mailing list.
==============================================================================
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: postgres@postgres.berkeley.edu
Cc: aoki@postgres.Berkeley.EDU, aataneja@cs.mtu.edu
Subject: Re: complex data types ..
In-Reply-To: <199405260507.WAA10327@faerie.CS.Berkeley.EDU>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox