We are trying to build an in-memory index in postgres using dsa.
Here is how we implemented dsa part.
We havePROC_DSA_AREAglobal variable(Process specific DSA Pointer)
We have a piece of traditional postgres shared memory to store dsa_handle
Each process that needs to use DSA, should create/attach DSA (based on dsa_handle stored in shmem)
Once created/attached, set the process dsa pointer toPROC_DSA_AREAvariable
Subsequent DSA access in that process will usePROC_DSA_AREAvariable with out looking to create/attach
Problem here is, on DSA Detach, i would like to resetPROC_DSA_AREAvariable to NULL. Otherwise subsequent DSA calls tries to use the same pointer and may end up into Segmentation Faults. How could i do that?
Found that there is a callback for dsa detach but that function requires segment pointer as an argument, Should be as below: