Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f3QC16393507 for ; Thu, 26 Apr 2001 08:01:06 -0400 (EDT) (envelope-from pgsql-interfaces-owner@postgresql.org) Received: from office.price.ru (office.price.ru [195.209.34.132]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3NG1m377154 for ; Mon, 23 Apr 2001 12:01:48 -0400 (EDT) (envelope-from alexey@workshop.price.ru) Received: from workshop.price.ru ([195.209.34.137] ident=alexey) by office.price.ru with esmtp (Exim 3.22 #1) id 14rimW-0000JR-00 for pgsql-interfaces@postgresql.org; Mon, 23 Apr 2001 20:01:44 +0400 Received: by workshop.price.ru (8.9.3+Sun/8.9.1) id UAA09319 for pgsql-interfaces@postgresql.org; Mon, 23 Apr 2001 20:01:41 +0400 (MSD) From: Alexey Nalbat Reply-To: alexey@price.ru Organization: Price Express To: pgsql-interfaces@postgresql.org Subject: can external C-function get multiple rows? Date: Mon, 23 Apr 2001 19:35:22 +0400 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain; charset="koi8-r" MIME-Version: 1.0 Message-Id: <01042320014100.09239@workshop.price.ru> Content-Transfer-Encoding: 8bit X-Archive-Number: 200104/112 X-Sequence-Number: 1496 I want my external C-function 'triple(int4)' to return multiple rows as 'SETOF int4' in order to be used in the sql-statement 'select a.plno,a.prod from ( select * from plprice_00_1 ) a, ( select triple(17366760) as plno ) b where a.plno=b.plno'. Table 'plprice_00_1' is pl=# \d plprice_00_1 Table "plprice_00_1" Attribute | Type | Modifier -----------+---------------+----------- plno | integer | not null prod | varchar(512) | Indices: i_prc_prod_00_1, pk_prc_plno_00_1 with primary key pl=# \d pk_prc_plno_00_1 Index "pk_prc_plno_00_1" Attribute | Type -----------+--------- plno | integer unique btree (primary key) I created C-function as #include int triple(int i) { int *n = (int *)malloc(3*sizeof(int)); n[0] = i; n[1] = 2*i; n[2] = 3*i; return *n; } and compiledit on Solaris using # gcc -fpic -c triple.c # gcc -G -o triple.so triple.o Creating function in psql made no error # CREATE FUNCTION triple(int4) RETURNS SETOF int4 AS '/var/local/lib/pgsql/lib/triple.so' LANGUAGE 'C'; CREATE And now it just hung up (after pressing ^C it came back with "Cancel request sent ERROR: Query was cancelled.") when I call # select triple(1); So, can C-function return multiple rows? And if yes, what was my error? Thanks in advance. P.S.: Excuse me for bad english. -- Alexey Nalbat