[GENERAL] Unstable C Function

2016-09-21 Thread Ian Campbell
I'm running PG 9.5 on Win 10 64-bit. I'm compiling C under VS 2016. I am forming a function that will evolve into a somewhat complex beast. To test out my initial efforts, the function accepts an array of int4 (this works fine and the code for processing it is not shown here). The function then gr

Re: [GENERAL] Unstable C Function

2016-09-21 Thread Ian Campbell
Thanks for personally replying, Tom. I appreciate it. You are correct. In the interim, I found the following change solved the issue: SPI_finish(); // move to here SRF_RETURN_DONE(funcctx); I'll look into tuplestore. Thanks for the hint. Fixed IMMUTABLE. Regards Ian Campbell On Thu, S

Re: [GENERAL] Unstable C Function

2016-09-22 Thread Ian Campbell
I'm going to rewrite it to use your tuplestore suggestion. OK, so SPI is only suitable for single-call functions, right? If another function in the query attempted to use SPI, I assume there would be a deadlock? Regards, Ian On Thu, Sep 22, 2016 at 7:25 PM Tom Lane wrote: > Ian

[GENERAL] Use SPI_exec... to insert multiples rows in C

2016-09-25 Thread Ian Campbell
I need to insert up to 12 rows (bulk). Basically, new row #1's ID is the table sequence nextval and parent = null; #2 is nextval + 1 and parent = row #1's ID, etc. A hierarchy. I figured the most performant way to do this is to have the sequence increment by the max bulk insert quantity, 12. This