Skip site navigation (1) Skip section navigation (2)

Re: Re: Support for %TYPE in CREATE FUNCTION

From: Michael Samuel <michael(at)miknet(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: Support for %TYPE in CREATE FUNCTION
Date: 2001-06-01 13:11:13
Message-ID: 20010601231113.A5405@miknet.net (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
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(at)miknet(dot)net>

In response to

Responses

pgsql-hackers by date

Next:From: Jan WieckDate: 2001-06-01 13:31:05
Subject: Re: Access statistics
Previous:From: Oleg BartunovDate: 2001-06-01 09:41:53
Subject: Re: First version of multi-key index support for GiST

pgsql-patches by date

Next:From: Peter EisentrautDate: 2001-06-01 15:04:10
Subject: Re: Fw: Isn't pg_statistic a security hole - Solution Proposal
Previous:From: Zeugswetter Andreas SBDate: 2001-06-01 07:55:54
Subject: AW: Re: Support for %TYPE in CREATE FUNCTION

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group