diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-08-16 19:27:46 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-08-16 19:27:46 -0400 |
commit | b5282aa893e565b7844f8237462cb843438cdd5e (patch) | |
tree | b19170597a0a94685cc8c978c1c5800c411d02d1 /src/backend/access/heap/heapam.c | |
parent | 632ae6829f7abda34e15082c91d9dfb3fc0f298b (diff) | |
download | postgresql-b5282aa893e565b7844f8237462cb843438cdd5e.tar.gz postgresql-b5282aa893e565b7844f8237462cb843438cdd5e.zip |
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.
Diffstat (limited to 'src/backend/access/heap/heapam.c')
-rw-r--r-- | src/backend/access/heap/heapam.c | 30 |
1 files changed, 15 insertions, 15 deletions
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) @@ -2945,14 +2948,6 @@ l2: 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. */ if (have_tuple_lock) @@ -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); } |