Functions in C with Ornate Data Structures - Mailing list pgsql-novice

From Stephen P. Berry
Subject Functions in C with Ornate Data Structures
Date
Msg-id 20020119002433.EAADC106FC@schadenfreude.meshuggeneh.net
Whole thread Raw
Responses Re: Functions in C with Ornate Data Structures  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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-----

pgsql-novice by date:

Previous
From: Andrew McMillan
Date:
Subject: Re: Full-text searching in PostgreaSQL - Using GiST for
Next
From: Tom Lane
Date:
Subject: Re: Functions in C with Ornate Data Structures