Re: [HACKERS] Custom Data Type Question

2006-11-18 Thread Simon Riggs
On Wed, 2006-11-15 at 16:38 -0500, Andrew Dunstan wrote: My little enumkit tool allows you to create enumerations today very easily, but its values are completely hardcoded. However, the above trick still works. The downside is that each enumeration type requires a tiny bit of compilation.

Re: [HACKERS] Custom Data Type Question

2006-11-18 Thread Andrew Dunstan
Simon Riggs wrote: On Wed, 2006-11-15 at 16:38 -0500, Andrew Dunstan wrote: My little enumkit tool allows you to create enumerations today very easily, but its values are completely hardcoded. However, the above trick still works. The downside is that each enumeration type requires a

Re: [HACKERS] Custom Data Type Question

2006-11-16 Thread Greg Mitchell
A simpler way to do this might be to only cache the list per query context. In your IO functions, you could whack a pointer to your cache onto fcinfo-flinfo-fn_extra, and the same flinfo gets passed in for e.g. all output function calls for that column for that query, IIRC. This was what I had

Re: [HACKERS] Custom Data Type Question

2006-11-16 Thread Greg Mitchell
As far as memory management goes, do I just use hash_create() and assign that pointer to fn_extra and at the end of the query it will be freed? Or will it not be freed until this end of the transaction? I'm really having trouble understanding the memory management issues with Postgres. Greg

Re: [HACKERS] Custom Data Type Question

2006-11-16 Thread Andrew Dunstan
Greg Mitchell wrote: Also, are there any ADTs like a hash-map or tree-map in the server libraries (my background is C++ and am use to having std::map) or do I need to role my own? Look at the dynahash code. I just used it for the first time in a plperl patch, and it's reasonably

Re: [HACKERS] Custom Data Type Question

2006-11-16 Thread Tom Lane
Greg Mitchell [EMAIL PROTECTED] writes: As far as memory management goes, do I just use hash_create() and assign that pointer to fn_extra and at the end of the query it will be freed? Or will it not be freed until this end of the transaction? I'm really having trouble understanding the

[HACKERS] Custom Data Type Question

2006-11-15 Thread Greg Mitchell
I'm trying to create a custom data type similar to an enumeration type. However, I'd like the mapping of the int-string to be dynamic instead of hard coded. I'd like to have a table that contains this mapping that can be appended to. Creating this type is not very difficult. However, for

Re: [HACKERS] Custom Data Type Question

2006-11-15 Thread Andrew Dunstan
Greg Mitchell wrote: I'm trying to create a custom data type similar to an enumeration type. However, I'd like the mapping of the int-string to be dynamic instead of hard coded. I'd like to have a table that contains this mapping that can be appended to. Creating this type is not very

Re: [HACKERS] Custom Data Type Question

2006-11-15 Thread Tom Dunstan
Hi Greg Greg Mitchell wrote: I'm trying to create a custom data type similar to an enumeration type. However, I'd like the mapping of the int-string to be dynamic instead of hard coded. I'd like to have a table that contains this mapping that can be appended to. Creating this type is not