creating aggregates that work on composite types (whole tuples) - Mailing list pgsql-hackers

From Hannu Krosing
Subject creating aggregates that work on composite types (whole tuples)
Date
Msg-id 1027621076.29994.13.camel@taru.tm.ee
Whole thread Raw
Responses Re: creating aggregates that work on composite types (whole tuples)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I am trying to create an aggregate function that works on whole tuples,
but the system does not find them once defined ;(

hannu=# \d users                              Table "users" Column  |  Type   |                     
Modifiers                       
----------+---------+------------------------------------------------------fname    | text    | not nulllname    | text
  | not nullusername | text    | userid   | integer | not null 
 

hannu=# create or replace function add_table_row(text,users) returns
text as
hannu-# 'state = args[0]
hannu'# user = args[1]["fname"] + ":" + args[1]["lname"]
hannu'# if state:
hannu'#     return state + "\\n" + user 
hannu'# else:
hannu'#     return user
hannu'# '
hannu-# LANGUAGE 'plpython';
CREATE
hannu=# select add_table_row('',users) from users;add_table_row 
---------------jane:doejohn:doewillem:doerick:smith
(4 rows)
hannu=# create aggregate tabulate (
hannu(#     basetype = users,
hannu(#     sfunc = add_table_row,
hannu(#     stype = text,
hannu(#     initcond = ''
hannu(# );
CREATE
hannu=# select tabulate(users) from users;
ERROR:  No such attribute or function 'tabulate'



What am I doing wrong ?

--------------
Hannu



pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: why?
Next
From: Marc Lavergne
Date:
Subject: Re: Oracle Decode Function