Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-06 Thread Tom Lane
James William Pye <[EMAIL PROTECTED]> writes: > On Sun, May 07, 2006 at 12:16:16AM +0200, Thomas Hallgren wrote: >> Why are there two ways of representing some of the array types? I mean, >> why is there an _int4 when you could just as well write int4[]? I'm >> probably missing the point altogeth

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-06 Thread James William Pye
On Sun, May 07, 2006 at 12:16:16AM +0200, Thomas Hallgren wrote: > Yes, the intarray stuff was very helpful but also somewhat confusing. > Why are there two ways of representing some of the array types? I mean, > why is there an _int4 when you could just as well write int4[]? I'm > probably miss

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-06 Thread Tom Lane
Thomas Hallgren <[EMAIL PROTECTED]> writes: > Yes, of course. I see that now. I was unaware that a function had an > associated "user data". What's the semantics associated with the > fn_extra? Does it retain its setting throughout a session (i.e. the > lifetime of the backend process)? No, jus

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-06 Thread Thomas Hallgren
Martijn van Oosterhout wrote: Looking at contrib/intarray/_int_op.c might help. It does something like this: ArrayType *a = (ArrayType *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0))); The file src/include/utils/array.h also seems to have many useful functions. Hope this

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-06 Thread Thomas Hallgren
Tom Lane wrote: Make a struct that can hold two ArrayMetaStates. Or whatever else you need. What a C function keeps in fn_extra is its own affair. Yes, of course. I see that now. I was unaware that a function had an associated "user data". What's the semantics associated with the fn_extra

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-06 Thread Tom Lane
Thomas Hallgren <[EMAIL PROTECTED]> writes: > The thing that makes me a bit confused is the > ArrayMetaState. The functions obtain it using: > my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; > which is fine if there's only one array parameter. What happens if I > have two? Make a s

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-06 Thread Martijn van Oosterhout
On Sat, May 06, 2006 at 05:26:31PM +0200, Thomas Hallgren wrote: > I find very little information about how to write functions that deals > with arrays. My only source of information right now is the > arrayutils.c. Other pointers to docs and code are greatly appreciated. Looking at contrib/inta

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-06 Thread Thomas Hallgren
David Fetter wrote: On Thu, May 04, 2006 at 09:02:02PM +0200, Thomas Hallgren wrote: Tom Lane wrote: Why can PLs not handle pseudo-types? No one's done the work to figure out which ones are sensible to support and then add the logic needed to support them. PL/Java wil

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-04 Thread David Fetter
On Thu, May 04, 2006 at 09:02:02PM +0200, Thomas Hallgren wrote: > Tom Lane wrote: > > > Why can PLs not handle pseudo-types? > > > >No one's done the work to figure out which ones are sensible to > >support and then add the logic needed to support them. > > > PL/Java will handle the RECORD type co

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-04 Thread Tom Lane
Thomas Hallgren <[EMAIL PROTECTED]> writes: > PL/Java will handle the RECORD type correctly. I'm just finalizing a new, > more flexible, > type mapping implementation for PL/Java and it would be easy to add support > for more pseudo > types too. But what others would make sense? If you've got

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-04 Thread Thomas Hallgren
Tom Lane wrote: Why can PLs not handle pseudo-types? No one's done the work to figure out which ones are sensible to support and then add the logic needed to support them. PL/Java will handle the RECORD type correctly. I'm just finalizing a new, more flexible, type mapping implementation for

Re: [HACKERS] pseudo-type record arguments for PL-functions

2006-05-04 Thread Tom Lane
Markus Schiltknecht <[EMAIL PROTECTED]> writes: > What exactly are pseudo types? See http://developer.postgresql.org/docs/postgres/extend-type-system.html > Why can PLs not handle pseudo-types? No one's done the work to figure out which ones are sensible to support and then add the logic needed

[HACKERS] pseudo-type record arguments for PL-functions

2006-05-04 Thread Markus Schiltknecht
Hi, I'm trying to write a PL/Python function which is to be called from a rule. I'd need pass the OLD and NEW tuple records to the function. Unfortunately that does not work: 'pl/python functions cannot take type record'. What I have figured out by reading the source code: OLD and NEW are pseudo