|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.28 2000/10/11 21:28:19 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.29 2000/10/19 23:06:24 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -91,24 +91,37 @@ create_temp_relation(const char *relname, HeapTuple pg_class_tuple) |
91 | 91 | void |
92 | 92 | remove_all_temp_relations(void) |
93 | 93 | { |
| 94 | + /* skip xact start overhead if nothing to do */ |
| 95 | + if (temp_rels == NIL) |
| 96 | + return; |
| 97 | + |
94 | 98 | AbortOutOfAnyTransaction(); |
95 | 99 | StartTransactionCommand(); |
96 | 100 |
|
| 101 | + /* |
| 102 | + * The way this works is that each time through the loop, we delete |
| 103 | + * the frontmost entry. The DROP will call remove_temp_rel_by_relid() |
| 104 | + * as a side effect, thereby removing the entry in the temp_rels list. |
| 105 | + * So this is not an infinite loop, even though it looks like one. |
| 106 | + */ |
97 | 107 | while (temp_rels != NIL) |
98 | 108 | { |
99 | | - char relname[NAMEDATALEN]; |
100 | 109 | TempTable *temp_rel = (TempTable *) lfirst(temp_rels); |
101 | 110 |
|
102 | 111 | if (temp_rel->relkind != RELKIND_INDEX) |
103 | 112 | { |
| 113 | + char relname[NAMEDATALEN]; |
| 114 | + |
104 | 115 | /* safe from deallocation */ |
105 | 116 | strcpy(relname, temp_rel->user_relname); |
106 | 117 | heap_drop_with_catalog(relname, allowSystemTableMods); |
107 | 118 | } |
108 | 119 | else |
109 | 120 | index_drop(temp_rel->relid); |
| 121 | + /* advance cmd counter to make catalog changes visible */ |
110 | 122 | CommandCounterIncrement(); |
111 | 123 | } |
| 124 | + |
112 | 125 | CommitTransactionCommand(); |
113 | 126 | } |
114 | 127 |
|
|
0 commit comments