Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f3QC0T393225 for ; Thu, 26 Apr 2001 08:00:29 -0400 (EDT) (envelope-from pgsql-bugs-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 f3OGwQ395039 for ; Tue, 24 Apr 2001 12:58:26 -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 14s68s-0006Et-00 for pgsql-bugs@postgresql.org; Tue, 24 Apr 2001 20:58:22 +0400 Received: by workshop.price.ru (8.9.3+Sun/8.9.1) id UAA13075 for pgsql-bugs@postgresql.org; Tue, 24 Apr 2001 20:58:18 +0400 (MSD) From: Alexey Nalbat Reply-To: alexey@price.ru Organization: Price Express To: pgsql-bugs@postgresql.org Subject: c-function returning multiple rows Date: Tue, 24 Apr 2001 19:55:32 +0400 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain; charset="koi8-r" MIME-Version: 1.0 Message-Id: <01042420581800.12729@workshop.price.ru> Content-Transfer-Encoding: 8bit X-Archive-Number: 200104/203 X-Sequence-Number: 1277 Hello, I encountered the following problem ( at PostgreSQL 7.1 on Solaris i386 ) with compiling c-function returning multiple rows. Here is a transcript. +++ +++ postgres@beta:~$ cd lib/ postgres@beta:~/lib$ cat <myrand.c > #include > #include "postgres.h" > #include "fmgr.h" > #include "nodes/execnodes.h" > > PG_FUNCTION_INFO_V1(myrand); > > Datum > myrand(PG_FUNCTION_ARGS) > { > if ( 100*rand() > RAND_MAX ) > { > fcinfo->resultinfo->isDone = ExprMultipleResult; > PG_RETURN_INT32( PG_GETARG_INT32(0)*rand()/RAND_MAX ); > } > else > { > fcinfo->resultinfo->isDone = ExprEndResult; > PG_RETURN_NULL(); > } > } > ! postgres@beta:~/lib$ gcc -I /usr/local/include/pgsql -fpic -c myrand.c myrand.c: In function `triple': myrand.c:13: structure has no member named `isDone' myrand.c:18: structure has no member named `isDone' +++ +++ I digged into sources and supposed that line 61 in fmgr.h might be 'struct ReturnSetInfo *resultinfo;' instead of 'struct Node *resultinfo;'. But I'm not sure if it is correct. After changing this line in file fmgr.h it became working. Here is a transcript. +++ +++ postgres@beta:~/lib$ gcc -I /usr/local/include/pgsql -fpic -c myrand.c postgres@beta:~/lib$ gcc -G -o myrand.so myrand.o postgres@beta:~/lib$ psql Welcome to psql, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit postgres=# CREATE FUNCTION myrand(int4) RETURNS SETOF int4 AS '/var/local/lib/pgsql/lib/myrand.so' LANGUAGE 'C'; CREATE postgres=# SELECT myrand(50); ?column? ---------- 26 46 30 29 40 8 22 38 23 18 2 43 24 44 22 46 48 15 (18 rows) +++ +++ -- WBR, Alexey Nalbat