Re: Returning Composite Types from C functions

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Returning Composite Types from C functions
Дата
Msg-id 20050618133111.GA91368@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Returning Composite Types from C functions  ("John Hansen" <john@geeknet.com.au>)
Ответы Re: Returning Composite Types from C functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Sat, Jun 18, 2005 at 10:03:38PM +1000, John Hansen wrote:
> 
> There is a workaround tho, so should be fixable:
> 
> SELECT (a.b).* FROM (SELECT ('1:2:3:4:5'::text::my_type) AS b) AS a;
> 
> Or am I missing something?

I don't know enough about PostgreSQL internals so I'll have to defer
to the developers.  But here's a case where the above workaround
doesn't work -- in my tests, the cast function is called once per
column per row, or ten times:

CREATE TABLE foo (t text);
INSERT INTO foo VALUES ('1:2:3:4:5');
INSERT INTO foo VALUES ('6:7:8:9:10');
SELECT (a.b).* FROM (SELECT t::my_type AS b FROM foo) AS a;

What do you get?  Can you think of a workaround for this case?
Maybe one of the developers can comment on why your example calls
the function only once and mine calls it multiple times per row,
even though they look similar.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: LGPL
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Returning Composite Types from C functions