Re: Re: Support for %TYPE in CREATE FUNCTION - Mailing list pgsql-hackers

From Michael Samuel
Subject Re: Re: Support for %TYPE in CREATE FUNCTION
Date
Msg-id 20010601231113.A5405@miknet.net
Whole thread Raw
In response to Re: Support for %TYPE in CREATE FUNCTION  (Pascal Scheffers <pascal@scheffers.net>)
Responses Re: Re: Support for %TYPE in CREATE FUNCTION  (Ian Lance Taylor <ian@airs.com>)
List pgsql-hackers
I've been thinking about this, and I think the smartest way to implement
%TYPE would be to have it as a special-case data type.  So, the C
representation of it would be something like this:

struct PercentType {int datatype;void *data;
};

Note: I made the datatype field an int, but that may/may not be the
correct datatype to use there.

And basically, postgres can resolve at runtime what it should point to,
and the code should have to deal with it, either via casting, or throwing
an exception if it's unacceptable.

Of course, there'd be a small overhead within the function, but it's a
small price to pay for a robust implementation.

As for operator overloading, a decision must be made whether you search
for a more specific function first, or for a matching %TYPE.

Of course, this may be too many special cases to be coded cleanly...

-- 
Michael Samuel <michael@miknet.net>


pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: First version of multi-key index support for GiST
Next
From: Jan Wieck
Date:
Subject: Re: Access statistics