Skip to content

Commit f41f8ee

Browse files
committed
Fix temp relation handling for indexes, cleanup
1 parent 75e3ba3 commit f41f8ee

File tree

5 files changed

+21
-32
lines changed

5 files changed

+21
-32
lines changed

src/backend/access/transam/xact.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.71 2000/09/27 10:41:55 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.72 2000/10/11 21:28:17 momjian Exp $
1212
*
1313
* NOTES
1414
* Transaction aborts can now occur two ways:
@@ -1119,7 +1119,7 @@ AbortTransaction()
11191119
AtEOXact_portals();
11201120
RecordTransactionAbort();
11211121
RelationPurgeLocalRelation(false);
1122-
invalidate_temp_relations();
1122+
remove_temp_rel_in_myxid();
11231123
AtEOXact_SPI();
11241124
AtEOXact_nbtree();
11251125
AtAbort_Cache();

src/backend/catalog/heap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.147 2000/10/05 19:48:21 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.148 2000/10/11 21:28:18 momjian Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -131,11 +131,11 @@ static FormData_pg_attribute a6 = {
131131
MaxCommandIdAttributeNumber, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0'
132132
};
133133

134-
/*
134+
/*
135135
We decide to call this attribute "tableoid" rather than say
136136
"classoid" on the basis that in the future there may be more than one
137137
table of a particular class/type. In any case table is still the word
138-
used in SQL.
138+
used in SQL.
139139
*/
140140
static FormData_pg_attribute a7 = {
141141
0xffffffff, {"tableoid"}, OIDOID, 0, sizeof(Oid),
@@ -1489,7 +1489,7 @@ heap_drop_with_catalog(const char *relname,
14891489
RelationForgetRelation(rid);
14901490

14911491
if (istemp)
1492-
remove_temp_relation(rid);
1492+
remove_temp_rel_by_relid(rid);
14931493

14941494
if (has_toasttable)
14951495
{

src/backend/catalog/index.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.127 2000/10/05 19:48:21 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.128 2000/10/11 21:28:18 momjian Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1145,7 +1145,7 @@ index_drop(Oid indexId)
11451145
RelationForgetRelation(indexId);
11461146

11471147
/* does something only if it is a temp index */
1148-
remove_temp_relation(indexId);
1148+
remove_temp_rel_by_relid(indexId);
11491149
}
11501150

11511151
/* ----------------------------------------------------------------
@@ -1374,7 +1374,7 @@ IndexesAreActive(Oid relid, bool confirmCommitted)
13741374
if (!LockClassinfoForUpdate(relid, &tuple, &buffer, confirmCommitted))
13751375
elog(ERROR, "IndexesAreActive couldn't lock %u", relid);
13761376
if (((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_RELATION &&
1377-
((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_TOASTVALUE)
1377+
((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_TOASTVALUE)
13781378
elog(ERROR, "relation %u isn't an indexable relation", relid);
13791379
isactive = ((Form_pg_class) GETSTRUCT(&tuple))->relhasindex;
13801380
ReleaseBuffer(buffer);

src/backend/utils/cache/temprel.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.27 2000/07/12 18:04:45 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.28 2000/10/11 21:28:19 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -91,35 +91,24 @@ create_temp_relation(const char *relname, HeapTuple pg_class_tuple)
9191
void
9292
remove_all_temp_relations(void)
9393
{
94-
List *l,
95-
*next;
96-
97-
if (temp_rels == NIL)
98-
return;
99-
10094
AbortOutOfAnyTransaction();
10195
StartTransactionCommand();
10296

103-
l = temp_rels;
104-
while (l != NIL)
97+
while (temp_rels != NIL)
10598
{
106-
TempTable *temp_rel = (TempTable *) lfirst(l);
107-
108-
next = lnext(l); /* do this first, l is deallocated */
99+
char relname[NAMEDATALEN];
100+
TempTable *temp_rel = (TempTable *) lfirst(temp_rels);
109101

110-
/* Indexes are dropped during heap drop */
111102
if (temp_rel->relkind != RELKIND_INDEX)
112103
{
113-
char relname[NAMEDATALEN];
114-
115104
/* safe from deallocation */
116105
strcpy(relname, temp_rel->user_relname);
117106
heap_drop_with_catalog(relname, allowSystemTableMods);
118107
}
119-
120-
l = next;
108+
else
109+
index_drop(temp_rel->relid);
110+
CommandCounterIncrement();
121111
}
122-
temp_rels = NIL;
123112
CommitTransactionCommand();
124113
}
125114

@@ -129,7 +118,7 @@ remove_all_temp_relations(void)
129118
* we don't have the relname for indexes, so we just pass the oid
130119
*/
131120
void
132-
remove_temp_relation(Oid relid)
121+
remove_temp_rel_by_relid(Oid relid)
133122
{
134123
MemoryContext oldcxt;
135124
List *l,
@@ -179,7 +168,7 @@ remove_temp_relation(Oid relid)
179168
* We just have to delete the map entry.
180169
*/
181170
void
182-
invalidate_temp_relations(void)
171+
remove_temp_rel_in_myxid(void)
183172
{
184173
MemoryContext oldcxt;
185174
List *l,

src/include/utils/temprel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: temprel.h,v 1.10 2000/06/20 06:41:11 tgl Exp $
10+
* $Id: temprel.h,v 1.11 2000/10/11 21:28:19 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -18,12 +18,12 @@
1818

1919
extern void create_temp_relation(const char *relname,
2020
HeapTuple pg_class_tuple);
21-
extern void remove_temp_relation(Oid relid);
21+
extern void remove_temp_rel_by_relid(Oid relid);
2222
extern bool rename_temp_relation(const char *oldname,
2323
const char *newname);
2424

2525
extern void remove_all_temp_relations(void);
26-
extern void invalidate_temp_relations(void);
26+
extern void remove_temp_rel_in_myxid(void);
2727

2828
extern char *get_temp_rel_by_username(const char *user_relname);
2929
extern char *get_temp_rel_by_physicalname(const char *relname);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy