Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-novice by date

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

pgsql-hackers by date

Next:From: Laurette CisnerosDate: 2002-01-19 00:26:29
Subject: pg_dump question
Previous:From: ArguileDate: 2002-01-18 23:57:08
Subject: Re: Confusing terminology

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group