Problem with PlPgsql function on composite types

Поиск
Список
Период
Сортировка
От tolik@icomm.ru (Anatoly K. Lasareff)
Тема Problem with PlPgsql function on composite types
Дата
Msg-id x7n25ebk9u.fsf@tolikus.hq.aaanet.ru
обсуждение исходный текст
Список pgsql-general
Hi, all!

I use postgres 6.4 under FreeBSD.

I create table 'a':

Table    = a
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                | Length|
+----------------------------------+----------------------------------+-------+
| dt                               | datetime                         |     8 |
| i                                | int4                             |     4 |
+----------------------------------+----------------------------------+-------+

with some values:

tolik=> select * from a;
dt                          |i
----------------------------+-
Thu Nov 26 16:35:23 1998 MSK|1
Wed Nov 25 00:00:00 1998 MSK|2
Fri Nov 27 00:00:00 1998 MSK|3
(3 rows)


Then I create simple function:

--------------------------------------
create function fff(a) returns a as
'
declare
  inp    alias for $1;
begin
  raise notice ''i=% dt=%'', inp.i, inp.dt;
  return inp;
end;
'
language 'plpgsql';
--------------------------------------

This function returns its input argument without changing and notice
values of input row. When I execute statement

select dt(fff(a));

I get follow output:
-----------------------------------------------

NOTICE:  i=1 dt=Thu Nov 26 16:35:23 1998 MSK
NOTICE:  i=<NULL> dt=<NULL>
NOTICE:  i=2 dt=Wed Nov 25 00:00:00 1998 MSK
NOTICE:  i=<NULL> dt=<NULL>
NOTICE:  i=3 dt=Fri Nov 27 00:00:00 1998 MSK
NOTICE:  i=<NULL> dt=<NULL>
dt
----------------------------
Sat Jan 01 03:00:00 2000 MSK
Sat Jan 01 03:00:00 2000 MSK
Sat Jan 01 03:00:00 2000 MSK
(3 rows)
-----------------------------------------------

My questions are:

1) why the function calls 6 times, but not 3 times

2) what the data are in this output

3) how can I right write function, working with composite types?

Help me, please...

--
Anatoly K. Lasareff              Email:       tolik@icomm.ru

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

Предыдущее
От: Oleg Broytmann
Дата:
Сообщение: Re: [GENERAL] table protections?
Следующее
От: Stuart Rison
Дата:
Сообщение: [GENERAL] Typecasting datetype as date. How do I cope with NULLs?