Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3114102

Browse files
committed
Reimplement temp tables using schemas. The temp table map is history;
temp table entries in pg_class have the names the user would expect.
1 parent5f4745a commit3114102

File tree

29 files changed

+596
-670
lines changed

29 files changed

+596
-670
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 2 additions & 5 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.118 2002/03/15 19:20:29 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.119 2002/03/31 06:26:29 tgl Exp $
1212
*
1313
* NOTES
1414
*Transaction aborts can now occur two ways:
@@ -178,10 +178,9 @@
178178
#include"utils/portal.h"
179179
#include"utils/catcache.h"
180180
#include"utils/relcache.h"
181-
#include"utils/temprel.h"
182-
183181
#include"pgstat.h"
184182

183+
185184
externboolSharedBufferChanged;
186185

187186
staticvoidAbortTransaction(void);
@@ -999,7 +998,6 @@ CommitTransaction(void)
999998
*/
1000999

10011000
RelationPurgeLocalRelation(true);
1002-
AtEOXact_temp_relations(true);
10031001
smgrDoPendingDeletes(true);
10041002

10051003
AtEOXact_SPI();
@@ -1102,7 +1100,6 @@ AbortTransaction(void)
11021100
}
11031101

11041102
RelationPurgeLocalRelation(false);
1105-
AtEOXact_temp_relations(false);
11061103
smgrDoPendingDeletes(false);
11071104

11081105
AtEOXact_SPI();

‎src/backend/access/transam/xlogutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.22 2002/03/02 21:39:20 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.23 2002/03/31 06:26:29 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -335,7 +335,7 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
335335
{
336336
res=_xl_new_reldesc();
337337

338-
sprintf(RelationGetPhysicalRelationName(&(res->reldata)),"%u",rnode.relNode);
338+
sprintf(RelationGetRelationName(&(res->reldata)),"%u",rnode.relNode);
339339

340340
/* unexisting DB id */
341341
res->reldata.rd_lockInfo.lockRelId.dbId=RecoveryDb;

‎src/backend/bootstrap/bootparse.y

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.41 2002/03/26 19:15:16 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.42 2002/03/31 06:26:29 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -184,7 +184,7 @@ Boot_CreateStmt:
184184
reldesc =heap_create(LexIDStr($4),
185185
PG_CATALOG_NAMESPACE,
186186
tupdesc,
187-
false,true,true);
187+
true,true);
188188
reldesc->rd_rel->relhasoids = ! ($3);
189189
elog(DEBUG3,"bootstrap relation created");
190190
}
@@ -199,7 +199,6 @@ Boot_CreateStmt:
199199
tupdesc,
200200
RELKIND_RELATION,
201201
! ($3),
202-
false,
203202
true);
204203
elog(DEBUG3,"relation created with oid %u", id);
205204
}

‎src/backend/catalog/aclchk.c

Lines changed: 1 addition & 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/aclchk.c,v 1.60 2002/03/29 19:05:59 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.61 2002/03/31 06:26:29 tgl Exp $
1212
*
1313
* NOTES
1414
* See acl.h.
@@ -40,7 +40,6 @@
4040
#include"parser/parse_type.h"
4141
#include"utils/acl.h"
4242
#include"utils/syscache.h"
43-
#include"utils/temprel.h"
4443

4544

4645
staticvoidExecuteGrantStmt_Table(GrantStmt*stmt);
@@ -811,7 +810,6 @@ pg_class_aclcheck(Oid table_oid, Oid userid, AclMode mode)
811810
relname=NameStr(((Form_pg_class)GETSTRUCT(tuple))->relname);
812811
if ((mode& (ACL_INSERT |ACL_UPDATE |ACL_DELETE))&&
813812
!allowSystemTableMods&&IsSystemRelationName(relname)&&
814-
!is_temp_relname(relname)&&
815813
!usecatupd)
816814
{
817815
#ifdefACLDEBUG

‎src/backend/catalog/heap.c

Lines changed: 16 additions & 71 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.193 2002/03/29 19:05:59 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.194 2002/03/31 06:26:29 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -61,14 +61,12 @@
6161
#include"utils/lsyscache.h"
6262
#include"utils/relcache.h"
6363
#include"utils/syscache.h"
64-
#include"utils/temprel.h"
6564

6665

6766
staticvoidAddNewRelationTuple(Relationpg_class_desc,
6867
Relationnew_rel_desc,
6968
Oidnew_rel_oid,Oidnew_type_oid,
70-
charrelkind,boolrelhasoids,
71-
char*temp_relname);
69+
charrelkind,boolrelhasoids);
7270
staticvoidDeleteAttributeTuples(Relationrel);
7371
staticvoidDeleteRelationTuple(Relationrel);
7472
staticvoidDeleteTypeTuple(Relationrel);
@@ -205,34 +203,29 @@ SystemAttributeByName(const char *attname, bool relhasoids)
205203
*
206204
*Remove the system relation specific code to elsewhere eventually.
207205
*
208-
* NOTE: if istemp is TRUE then heap_create will overwrite relname with
209-
* the unique "real" name chosen for the temp relation.
210-
*
211206
* If storage_create is TRUE then heap_storage_create is called here,
212207
* else caller must call heap_storage_create later.
213208
* ----------------------------------------------------------------
214209
*/
215210
Relation
216-
heap_create(char*relname,
211+
heap_create(constchar*relname,
217212
Oidrelnamespace,
218213
TupleDesctupDesc,
219-
boolistemp,
220214
boolstorage_create,
221215
boolallow_system_table_mods)
222216
{
223-
staticunsignedintuniqueId=0;
224-
225217
Oidrelid;
226218
Oiddbid=MyDatabaseId;
227-
RelFileNodernode;
228219
boolnailme= false;
220+
RelFileNodernode;
229221
Relationrel;
230222

231223
/*
232224
* sanity checks
233225
*/
234-
if (relname&& !allow_system_table_mods&&
235-
IsSystemRelationName(relname)&&IsNormalProcessingMode())
226+
if (!allow_system_table_mods&&
227+
IsSystemRelationName(relname)&&
228+
IsNormalProcessingMode())
236229
elog(ERROR,"invalid relation name \"%s\"; "
237230
"the 'pg_' name prefix is reserved for system catalogs",
238231
relname);
@@ -291,16 +284,6 @@ heap_create(char *relname,
291284
else
292285
relid=newoid();
293286

294-
if (istemp)
295-
{
296-
/*
297-
* replace relname of caller with a unique name for a temp
298-
* relation
299-
*/
300-
snprintf(relname,NAMEDATALEN,"%s_%d_%u",
301-
PG_TEMP_REL_PREFIX, (int)MyProcPid,uniqueId++);
302-
}
303-
304287
/*
305288
* For now, the physical identifier of the relation is the same as the
306289
* logical identifier.
@@ -528,8 +511,7 @@ AddNewRelationTuple(Relation pg_class_desc,
528511
Oidnew_rel_oid,
529512
Oidnew_type_oid,
530513
charrelkind,
531-
boolrelhasoids,
532-
char*temp_relname)
514+
boolrelhasoids)
533515
{
534516
Form_pg_classnew_rel_reltup;
535517
HeapTupletup;
@@ -599,9 +581,6 @@ AddNewRelationTuple(Relation pg_class_desc,
599581
*/
600582
heap_insert(pg_class_desc,tup);
601583

602-
if (temp_relname)
603-
create_temp_relation(temp_relname,tup);
604-
605584
if (!IsIgnoringSystemIndexes())
606585
{
607586
/*
@@ -669,19 +648,17 @@ AddNewRelationType(const char *typeName,
669648
* --------------------------------
670649
*/
671650
Oid
672-
heap_create_with_catalog(char*relname,
651+
heap_create_with_catalog(constchar*relname,
673652
Oidrelnamespace,
674653
TupleDesctupdesc,
675654
charrelkind,
676655
boolrelhasoids,
677-
boolistemp,
678656
boolallow_system_table_mods)
679657
{
680658
Relationpg_class_desc;
681659
Relationnew_rel_desc;
682660
Oidnew_rel_oid;
683661
Oidnew_type_oid;
684-
char*temp_relname=NULL;
685662

686663
/*
687664
* sanity checks
@@ -693,32 +670,17 @@ heap_create_with_catalog(char *relname,
693670

694671
CheckAttributeNames(tupdesc,relhasoids);
695672

696-
/* temp tables can mask non-temp tables */
697-
if ((!istemp&&get_relname_relid(relname,relnamespace))||
698-
(istemp&&is_temp_rel_name(relname)))
673+
if (get_relname_relid(relname,relnamespace))
699674
elog(ERROR,"Relation '%s' already exists",relname);
700675

701-
if (istemp)
702-
{
703-
/* save user relation name because heap_create changes it */
704-
temp_relname=pstrdup(relname);/* save original value */
705-
relname=palloc(NAMEDATALEN);
706-
strcpy(relname,temp_relname);/* heap_create will change this */
707-
}
708-
709676
/*
710677
* Tell heap_create not to create a physical file; we'll do that below
711678
* after all our catalog updates are done.(This isn't really
712679
* necessary anymore, but we may as well avoid the cycles of creating
713680
* and deleting the file in case we fail.)
714-
*
715-
* Note: The call to heap_create() changes relname for temp tables; it
716-
* becomes the true physical relname. The call to
717-
* heap_storage_create() does all the "real" work of creating the disk
718-
* file for the relation.
719681
*/
720682
new_rel_desc=heap_create(relname,relnamespace,tupdesc,
721-
istemp,false,allow_system_table_mods);
683+
false,allow_system_table_mods);
722684

723685
/* Fetch the relation OID assigned by heap_create */
724686
new_rel_oid=new_rel_desc->rd_att->attrs[0]->attrelid;
@@ -740,8 +702,7 @@ heap_create_with_catalog(char *relname,
740702
new_rel_oid,
741703
new_type_oid,
742704
relkind,
743-
relhasoids,
744-
temp_relname);
705+
relhasoids);
745706

746707
/*
747708
* since defining a relation also defines a complex type, we add a new
@@ -780,12 +741,6 @@ heap_create_with_catalog(char *relname,
780741
heap_close(new_rel_desc,NoLock);/* do not unlock till end of xact */
781742
heap_close(pg_class_desc,RowExclusiveLock);
782743

783-
if (istemp)
784-
{
785-
pfree(relname);
786-
pfree(temp_relname);
787-
}
788-
789744
returnnew_rel_oid;
790745
}
791746

@@ -1226,26 +1181,19 @@ heap_drop_with_catalog(Oid rid,
12261181
{
12271182
Relationrel;
12281183
OidtoasttableOid;
1229-
boolhas_toasttable;
1230-
boolistemp;
12311184
inti;
12321185

12331186
/*
12341187
* Open and lock the relation.
12351188
*/
12361189
rel=heap_open(rid,AccessExclusiveLock);
1237-
has_toasttable=rel->rd_rel->reltoastrelid!=InvalidOid;
12381190
toasttableOid=rel->rd_rel->reltoastrelid;
1239-
istemp=is_temp_rel_name(RelationGetRelationName(rel));
12401191

12411192
/*
12421193
* prevent deletion of system relations
12431194
*/
1244-
/* allow temp of pg_class? Guess so. */
1245-
if (!istemp&&
1246-
!allow_system_table_mods&&
1247-
IsSystemRelationName(RelationGetRelationName(rel))&&
1248-
!is_temp_relname(RelationGetRelationName(rel)))
1195+
if (!allow_system_table_mods&&
1196+
IsSystemRelationName(RelationGetRelationName(rel)))
12491197
elog(ERROR,"System relation \"%s\" may not be dropped",
12501198
RelationGetRelationName(rel));
12511199

@@ -1319,11 +1267,8 @@ heap_drop_with_catalog(Oid rid,
13191267
*/
13201268
RelationForgetRelation(rid);
13211269

1322-
/* and from the temp-table map */
1323-
if (istemp)
1324-
remove_temp_rel_by_relid(rid);
1325-
1326-
if (has_toasttable)
1270+
/* If it has a toast table, recurse to get rid of that too */
1271+
if (OidIsValid(toasttableOid))
13271272
heap_drop_with_catalog(toasttableOid, true);
13281273
}
13291274

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp