Use a private memory context to store rule information in each relcache
Tom Lane <tgl@sss.pgh.pa.us>
Use a private memory context to store rule information in each relcache entry that has rules. This allows us to release the rule parsetrees on relcache flush without needing a working freeObject() routine. Formerly, the rule trees were leaked permanently at relcache flush. Also, clean up handling of rule creation and deletion --- there was not sufficient locking of the relation being modified, and there was no reliable notification of other backends that a relcache reload was needed. Also, clean up relcache.c code so that scans of system tables needed to load a relcache entry are done in the caller's memory context, not in CacheMemoryContext. This prevents any un-pfreed memory from those scans from becoming a permanent memory leak.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/catalog/index.c | modified | +15 −24 |
| src/backend/commands/trigger.c | modified | +33 −15 |
| src/backend/rewrite/rewriteDefine.c | modified | +43 −80 |
| src/backend/rewrite/rewriteHandler.c | modified | +6 −6 |
| src/backend/rewrite/rewriteRemove.c | modified | +34 −39 |
| src/backend/rewrite/rewriteSupport.c | modified | +18 −178 |
| src/backend/utils/cache/relcache.c | modified | +188 −161 |
| src/include/catalog/index.h | modified | +3 −2 |
| src/include/rewrite/rewriteSupport.h | modified | +2 −9 |
| src/include/utils/rel.h | modified | +3 −2 |