From b5282aa893e565b7844f8237462cb843438cdd5e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 16 Aug 2011 19:27:46 -0400 Subject: Revise sinval code to remove no-longer-used tuple TID from inval messages. This requires adjusting the API for syscache callback functions: they now get a hash value, not a TID, to identify the target tuple. Most of them weren't paying any attention to that argument anyway, but plancache did require a small amount of fixing. Also, improve performance a trifle by avoiding sending duplicate inval messages when a heap_update isn't changing the catcache lookup columns. --- src/backend/access/heap/heapam.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/backend/access/heap/heapam.c') diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 9f1bcf1de4a..06db65d76f9 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -2028,7 +2028,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, * the heaptup data structure is all in local memory, not in the shared * buffer. */ - CacheInvalidateHeapTuple(relation, heaptup); + CacheInvalidateHeapTuple(relation, heaptup, NULL); pgstat_count_heap_insert(relation); @@ -2354,7 +2354,7 @@ l1: * boundary. We have to do this before releasing the buffer because we * need to look at the contents of the tuple. */ - CacheInvalidateHeapTuple(relation, &tp); + CacheInvalidateHeapTuple(relation, &tp, NULL); /* Now we can release the buffer */ ReleaseBuffer(buffer); @@ -2930,10 +2930,13 @@ l2: /* * Mark old tuple for invalidation from system caches at next command - * boundary. We have to do this before releasing the buffer because we - * need to look at the contents of the tuple. + * boundary, and mark the new tuple for invalidation in case we abort. + * We have to do this before releasing the buffer because oldtup is in + * the buffer. (heaptup is all in local memory, but it's necessary to + * process both tuple versions in one call to inval.c so we can avoid + * redundant sinval messages.) */ - CacheInvalidateHeapTuple(relation, &oldtup); + CacheInvalidateHeapTuple(relation, &oldtup, heaptup); /* Now we can release the buffer(s) */ if (newbuf != buffer) @@ -2944,14 +2947,6 @@ l2: if (BufferIsValid(vmbuffer)) ReleaseBuffer(vmbuffer); - /* - * If new tuple is cachable, mark it for invalidation from the caches in - * case we abort. Note it is OK to do this after releasing the buffer, - * because the heaptup data structure is all in local memory, not in the - * shared buffer. - */ - CacheInvalidateHeapTuple(relation, heaptup); - /* * Release the lmgr tuple lock, if we had it. */ @@ -3659,9 +3654,14 @@ heap_inplace_update(Relation relation, HeapTuple tuple) UnlockReleaseBuffer(buffer); - /* Send out shared cache inval if necessary */ + /* + * Send out shared cache inval if necessary. Note that because we only + * pass the new version of the tuple, this mustn't be used for any + * operations that could change catcache lookup keys. But we aren't + * bothering with index updates either, so that's true a fortiori. + */ if (!IsBootstrapProcessingMode()) - CacheInvalidateHeapTuple(relation, tuple); + CacheInvalidateHeapTuple(relation, tuple, NULL); } -- cgit v1.2.3