Thread: C Function Question
Hello, I have a C function that takes 4 arrays, does some math* to them, and ends up with an array of floats. I'd like to return this in standard postgres array form (ala SELECT) to be used in an subselect in an UPDATE query. Right now, this is all done in perl (which is perfectly adequate), but just for kicks I'd like to port it to C. The prob. is I can't seem to find a straightforward way to get from the array of floats to the postgres select form. I kick in the right direction would be great! Thanks, Bill * get the average of non-zero values in each array over each index. ending up with an array of averages.
Bill Triplett <btt@nethouse.com> writes: > The prob. is I can't seem to find a straightforward way to get from > the array of floats to the postgres select form. Take a look at the "FLOAT AGGREGATE OPERATORS" in src/backend/utils/adt/float.c. These show relatively simple code for assembling and disassembling fixed-size float arrays. regards, tom lane
On Mon, Feb 11, 2002 at 11:40:06AM -0500, Tom Lane wrote: > Bill Triplett <btt@nethouse.com> writes: > > The prob. is I can't seem to find a straightforward way to get from > > the array of floats to the postgres select form. > > Take a look at the "FLOAT AGGREGATE OPERATORS" in > src/backend/utils/adt/float.c. These show relatively simple code for > assembling and disassembling fixed-size float arrays. That is exactly what I needed... many thanks! Bill
Greetings. I've got a postgres server that's being hit rather heavily. I have many processes inititated by users (they start scripts running). Because of user impatience and idiocy, despite my explanations, they continue to re-run the script and not wait for the script to end the first time (i.e. 'why isn't it finishing? <click click click>'). So, I have about 9 postgres SELECTS going on right now that are pretty much runaway and useless. Can I safely kill these without fubaring things? I know killing the postmaster is Evil, but how about other processes? i'm going to get a call in a few moments now in complaint, and I'd like to be able to curb this right away. Adam -- Adam Bultman adam.bultman@iconideas.com 616-836-7213 http://www.iconideas.com
Adam Bultman <adam.bultman@iconideas.com> writes: > Greetings. I've got a postgres server that's being hit rather heavily. > I have many processes inititated by users (they start scripts running). > Because of user impatience and idiocy, despite my explanations, they > continue to re-run the script and not wait for the script to end the > first time (i.e. 'why isn't it finishing? <click click click>'). So, I > have about 9 postgres SELECTS going on right now that are pretty much > runaway and useless. Can I safely kill these without fubaring things? Yes. Best bet is to send them SIGINT, which will cause a clean query cancel, and then they'll notice the client connection went away and quit. More drastic measures might fool the postmaster into thinking that a backend crashed, in which case it'll force a database-wide restart, which you probably don't want. regards, tom lane