[HACKERS] Use of global and static variables in shared libraries

2007-09-14 Thread Don Walker
I'm in the process of converting some C functions written for another system into C functions in a shared library that will be used by PostgreSQL, The key function will be the state transition function for a user-defined aggregate. From what I've read in the documentation: 1. the state value

Re: [HACKERS] Use of global and static variables in shared libraries

2007-09-14 Thread Tom Lane
Don Walker [EMAIL PROTECTED] writes: Since my state is fairly complex I intend to make my state value type text to give myself a block of memory in which I can manage the various pointers I need. I realize that I will need to be careful about alignment issues and intend to store the state as a

Re: [HACKERS] Use of global and static variables in shared libraries

2007-09-14 Thread Don Walker
Q1 a) I will use bytea instead of text. Q1 b) I didn't intend to imply that my state value struct would contain pointers but thanks for reminding me that I should initialize any temporary pointers into the memory area using offsets. Q2 a) If I understand you correctly the use of static or global

Re: [HACKERS] Use of global and static variables in shared libraries

2007-09-14 Thread Heikki Linnakangas
Don Walker wrote: Q2 b) You seem to imply that, since the backend doesn't use threads, simultaneous single evaluations of my aggregate by different users/connections would not be a problem for the static or global variables. If 200 users want to evaluate my aggregate at the same time how does