|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.163 2002/04/27 21:24:34 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.164 2002/05/22 15:57:40 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -1841,35 +1841,39 @@ RelationForgetRelation(Oid rid)
|
1841 | 1841 |
|
1842 | 1842 | RelationIdCacheLookup(rid, relation);
|
1843 | 1843 |
|
1844 |
| - if (PointerIsValid(relation)) |
| 1844 | + if (!PointerIsValid(relation)) |
| 1845 | + return; /* not in cache, nothing to do */ |
| 1846 | + |
| 1847 | + if (!RelationHasReferenceCountZero(relation)) |
| 1848 | + elog(ERROR, "RelationForgetRelation: relation %u is still open", rid); |
| 1849 | + |
| 1850 | + /* If local, remove from list */ |
| 1851 | + if (relation->rd_myxactonly) |
1845 | 1852 | {
|
1846 |
| - if (relation->rd_myxactonly) |
1847 |
| - { |
1848 |
| - List *curr; |
1849 |
| - List *prev = NIL; |
| 1853 | + List *curr; |
| 1854 | + List *prev = NIL; |
1850 | 1855 |
|
1851 |
| - foreach(curr, newlyCreatedRelns) |
1852 |
| - { |
1853 |
| - Relation reln = lfirst(curr); |
| 1856 | + foreach(curr, newlyCreatedRelns) |
| 1857 | + { |
| 1858 | + Relation reln = lfirst(curr); |
1854 | 1859 |
|
1855 |
| - Assert(reln != NULL && reln->rd_myxactonly); |
1856 |
| - if (RelationGetRelid(reln) == rid) |
1857 |
| - break; |
1858 |
| - prev = curr; |
1859 |
| - } |
1860 |
| - if (curr == NIL) |
1861 |
| - elog(FATAL, "Local relation %s not found in list", |
1862 |
| - RelationGetRelationName(relation)); |
1863 |
| - if (prev == NIL) |
1864 |
| - newlyCreatedRelns = lnext(newlyCreatedRelns); |
1865 |
| - else |
1866 |
| - lnext(prev) = lnext(curr); |
1867 |
| - pfree(curr); |
| 1860 | + Assert(reln != NULL && reln->rd_myxactonly); |
| 1861 | + if (RelationGetRelid(reln) == rid) |
| 1862 | + break; |
| 1863 | + prev = curr; |
1868 | 1864 | }
|
1869 |
| - |
1870 |
| - /* Unconditionally destroy the relcache entry */ |
1871 |
| - RelationClearRelation(relation, false); |
| 1865 | + if (curr == NIL) |
| 1866 | + elog(ERROR, "Local relation %s not found in list", |
| 1867 | + RelationGetRelationName(relation)); |
| 1868 | + if (prev == NIL) |
| 1869 | + newlyCreatedRelns = lnext(newlyCreatedRelns); |
| 1870 | + else |
| 1871 | + lnext(prev) = lnext(curr); |
| 1872 | + pfree(curr); |
1872 | 1873 | }
|
| 1874 | + |
| 1875 | + /* Unconditionally destroy the relcache entry */ |
| 1876 | + RelationClearRelation(relation, false); |
1873 | 1877 | }
|
1874 | 1878 |
|
1875 | 1879 | /*
|
|
0 commit comments