Functions in C with Ornate Data Structures

From: "Stephen P(dot) Berry" <spb(at)meshuggeneh(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Cc: spb(at)meshuggeneh(dot)net
Subject: Functions in C with Ornate Data Structures
Date: 2002-01-19 00:24:33
Message-ID: 20020119002433.EAADC106FC@schadenfreude.meshuggeneh.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm trying to write C functions to handle some of the number crunching
that I have been doing via backend processing. Specifically, I want
to be able to construct a function such that a query like:

select crunch_number(foo) from bar where [some condition];

...where `foo' is the name of some column and `bar' is some table
name. The function needs to create some ornate data structures (i.e.,
doubly linked lists), and outputs some summary statistic.

If my data types were simpler, I could simply use an AGGREGATE function.
Unfortunately, I don't know of any way to schlep something as complex
as a doubly-linked list of arrays of arbitrary precision numbers.

I suppose ideally I'd like some way of either:

-Being able to call a function on each row (like most user-defined
functions) which only returns a result on the last row; or
-Being able to pass the table name, column name, and selection
conditions to the function, and walk through the matching rows
inside the function, returning a single result upon completion

In terms of logical structure, this looks similar to functions to do
things like compute means or standard deviations. The complication (as
far as I can tell) is because I can't get by with a simple accumulator
variable/transform function.

Is there any clean way to accomplish this in Postgres? Any pointers
or suggestions would be appreciated.

- -Steve

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.3 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8SLyyG3kIaxeRZl8RAsNNAKCy8YDnMMZCIGrMYT6pt2IxqxtCJwCgxFp2
HFlA8B9X5BJRfnMDmQSh8Ss=
=Kx46
-----END PGP SIGNATURE-----

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurette Cisneros 2002-01-19 00:26:29 pg_dump question
Previous Message Arguile 2002-01-18 23:57:08 Re: Confusing terminology

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2002-01-19 01:30:56 Re: Functions in C with Ornate Data Structures
Previous Message Andrew McMillan 2002-01-18 23:42:59 Re: Full-text searching in PostgreaSQL - Using GiST for