-
Does anybody know a rationale (if any) for not having a version of |
Beta Was this translation helpful? Give feedback.
Answered by
yrashk
Oct 18, 2024
Replies: 1 comment
-
@robertmhaas provided a great answer on Discord: When you call SPI_keepplan(), it calls SavedCachePlan() on each CachedPlanSource, which adds it to a global linked list called saved_plan_list. So if a saved plan where destroyed by deleting the memory context that contains it, then saved_plan_list would end up with garbage pointers in it, and the next access to that list would probably seg fault. So the purpose of putting the plan under CachedMemoryContext is to make sure that you always get rid of the plan using SPI_freeplan rather than any other tricky method. In theory, if you put it in some other memory context but still always explicitly used SPI_freeplan, everything would be fine. But if that other memory context were ever deleted, you'd have a disaster. So we use CacheMemoryContext, which is never deleted. Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
yrashk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@robertmhaas provided a great answer on Discord: