views:

32

answers:

1

Hi,

I'm trying to write a UDF in C that inserts values into a table and returns this table. The bigger picture is: I parse some document and set up a "parse table" (essentially this is the relational representation of the parse tree of the document parsed). After having inserted the parsing information into the parse table I need the UDF to return this "parse table" as it is needed as input for further operators.

If I use the SPI (SPI_execute) I can insert the data but can't read it out with a subsequent query (e.g. SELECT * from parseTable;) as the result of the subsequent query depends on the query before (at least I understood the manual this way).

I very much appreciate any help. I'm kind of stuck here.

Many thanks in advance,

Dietrich

A: 

Hello

there are a few samples

  1. postgresqlsrc/contrib/tablefunc/tablefunc.c
  2. http://www.pgsql.cz/index.php/Project_of_UDF_and_its_realization_at_C_for_PostgreSQL#Table_functions
  3. look to PostgreSQL's source code src/backend/utils/misc/guc.c/show_all_settings(), src/backend/utils/adt/misc.c/pg_get_keywords()
Pavel Stehule