|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.256 2007/02/27 23:48:09 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.257 2007/03/03 20:08:41 momjian Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -1915,9 +1915,6 @@ RelationCacheInvalidateEntry(Oid relationId) |
1915 | 1915 | * so we do not touch new-in-transaction relations; they cannot be targets |
1916 | 1916 | * of cross-backend SI updates (and our own updates now go through a |
1917 | 1917 | * separate linked list that isn't limited by the SI message buffer size). |
1918 | | - * We don't do anything special for newRelfilenode-in-transaction relations, |
1919 | | - * though since we have a lock on the relation nobody else should be |
1920 | | - * generating cache invalidation messages for it anyhow. |
1921 | 1918 | * |
1922 | 1919 | * We do this in two phases: the first pass deletes deletable items, and |
1923 | 1920 | * the second one rebuilds the rebuildable items. This is essential for |
@@ -1960,6 +1957,14 @@ RelationCacheInvalidate(void) |
1960 | 1957 | if (relation->rd_createSubid != InvalidSubTransactionId) |
1961 | 1958 | continue; |
1962 | 1959 |
|
| 1960 | + /* |
| 1961 | + * Reset newRelfilenode hint. It is never used for correctness, only |
| 1962 | + * for performance optimization. An incorrectly set hint can lead |
| 1963 | + * to data loss in some circumstances, so play safe. |
| 1964 | + */ |
| 1965 | + if (relation->rd_newRelfilenodeSubid != InvalidSubTransactionId) |
| 1966 | + relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; |
| 1967 | + |
1963 | 1968 | relcacheInvalsReceived++; |
1964 | 1969 |
|
1965 | 1970 | if (RelationHasReferenceCountZero(relation)) |
@@ -2011,6 +2016,17 @@ RelationCacheInvalidate(void) |
2011 | 2016 | list_free(rebuildList); |
2012 | 2017 | } |
2013 | 2018 |
|
| 2019 | +/* |
| 2020 | + * RelationCacheResetAtEOXact |
| 2021 | + * |
| 2022 | + * Register that work will be required at main-transaction commit or abort |
| 2023 | + */ |
| 2024 | +void |
| 2025 | +RelationCacheResetAtEOXact(void) |
| 2026 | +{ |
| 2027 | + need_eoxact_work = true; |
| 2028 | +} |
| 2029 | + |
2014 | 2030 | /* |
2015 | 2031 | * AtEOXact_RelationCache |
2016 | 2032 | * |
@@ -2161,7 +2177,7 @@ AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, |
2161 | 2177 | if (isCommit) |
2162 | 2178 | relation->rd_newRelfilenodeSubid = parentSubid; |
2163 | 2179 | else |
2164 | | - relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; |
| 2180 | + relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; |
2165 | 2181 | } |
2166 | 2182 |
|
2167 | 2183 | /* |
@@ -2255,7 +2271,7 @@ RelationBuildLocalRelation(const char *relname, |
2255 | 2271 | rel->rd_newRelfilenodeSubid = InvalidSubTransactionId; |
2256 | 2272 |
|
2257 | 2273 | /* must flag that we have rels created in this transaction */ |
2258 | | - need_eoxact_work = true; |
| 2274 | + RelationCacheResetAtEOXact(); |
2259 | 2275 |
|
2260 | 2276 | /* is it a temporary relation? */ |
2261 | 2277 | rel->rd_istemp = isTempNamespace(relnamespace); |
@@ -2911,7 +2927,7 @@ RelationSetIndexList(Relation relation, List *indexIds, Oid oidIndex) |
2911 | 2927 | relation->rd_oidindex = oidIndex; |
2912 | 2928 | relation->rd_indexvalid = 2; /* mark list as forced */ |
2913 | 2929 | /* must flag that we have a forced index list */ |
2914 | | - need_eoxact_work = true; |
| 2930 | + RelationCacheResetAtEOXact(); |
2915 | 2931 | } |
2916 | 2932 |
|
2917 | 2933 | /* |
|
0 commit comments