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

Commitdf13324

Browse files
committed
Add a "relistemp" boolean column to pg_class, which is true for temporary
relations (including a temp table's indexes and toast table/index), andfalse for normal relations. For ease of checking, this commit just addsthe column and fills it correctly --- revising the relation access machineryto use it will come separately.
1 parenteeeb782 commitdf13324

File tree

6 files changed

+69
-45
lines changed

6 files changed

+69
-45
lines changed

‎doc/src/sgml/catalogs.sgml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.199 2009/03/05 23:06:45 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.200 2009/03/31 17:59:55 tgl Exp $ -->
22
<!--
33
Documentation of the system catalogs, directed toward PostgreSQL developers
44
-->
@@ -1532,6 +1532,16 @@
15321532
</entry>
15331533
</row>
15341534

1535+
<row>
1536+
<entry><structfield>relistemp</structfield></entry>
1537+
<entry><type>bool</type></entry>
1538+
<entry></entry>
1539+
<entry>
1540+
True if this table is a temporary relation. If so, only the creating
1541+
session can safely access its contents
1542+
</entry>
1543+
</row>
1544+
15351545
<row>
15361546
<entry><structfield>relkind</structfield></entry>
15371547
<entry><type>char</type></entry>

‎src/backend/catalog/heap.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.351 2009/02/24 01:38:09 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.352 2009/03/31 17:59:56 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -664,6 +664,7 @@ InsertPgClassTuple(Relation pg_class_desc,
664664
values[Anum_pg_class_reltoastidxid-1]=ObjectIdGetDatum(rd_rel->reltoastidxid);
665665
values[Anum_pg_class_relhasindex-1]=BoolGetDatum(rd_rel->relhasindex);
666666
values[Anum_pg_class_relisshared-1]=BoolGetDatum(rd_rel->relisshared);
667+
values[Anum_pg_class_relistemp-1]=BoolGetDatum(rd_rel->relistemp);
667668
values[Anum_pg_class_relkind-1]=CharGetDatum(rd_rel->relkind);
668669
values[Anum_pg_class_relnatts-1]=Int16GetDatum(rd_rel->relnatts);
669670
values[Anum_pg_class_relchecks-1]=Int16GetDatum(rd_rel->relchecks);

‎src/backend/utils/cache/relcache.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.284 2009/01/27 12:40:15 petere Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.285 2009/03/31 17:59:56 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1396,6 +1396,12 @@ formrdesc(const char *relationName, Oid relationReltype,
13961396
*/
13971397
relation->rd_rel->relisshared= false;
13981398

1399+
/*
1400+
* Likewise, we must know if a relation is temp ... but formrdesc is
1401+
* not used for any temp relations.
1402+
*/
1403+
relation->rd_rel->relistemp= false;
1404+
13991405
relation->rd_rel->relpages=1;
14001406
relation->rd_rel->reltuples=1;
14011407
relation->rd_rel->relkind=RELKIND_RELATION;
@@ -2398,6 +2404,9 @@ RelationBuildLocalRelation(const char *relname,
23982404
*/
23992405
rel->rd_rel->relisshared=shared_relation;
24002406

2407+
/* it is temporary if and only if it is in my temp-table namespace */
2408+
rel->rd_rel->relistemp=isTempOrToastNamespace(relnamespace);
2409+
24012410
RelationGetRelid(rel)=relid;
24022411

24032412
for (i=0;i<natts;i++)

‎src/include/catalog/catversion.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.526 2009/03/25 22:19:02 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.527 2009/03/31 17:59:56 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200903251
56+
#defineCATALOG_VERSION_NO200903311
5757

5858
#endif

‎src/include/catalog/pg_attribute.h‎

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.146 2009/01/22 20:16:08 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.147 2009/03/31 17:59:56 tgl Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -409,17 +409,18 @@ DATA(insert ( 1249 tableoid26 0 4 -7 0 -1 -1 t p i t f f t 0 _null_));
409409
{ 1259, {"reltoastidxid"}, 26, -1,4, 11, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \
410410
{ 1259, {"relhasindex"}, 16, -1,1, 12, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
411411
{ 1259, {"relisshared"}, 16, -1,1, 13, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
412-
{ 1259, {"relkind"}, 18, -1,1, 14, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
413-
{ 1259, {"relnatts"}, 21, -1,2, 15, 0, -1, -1, true, 'p', 's', true, false, false, true, 0, { 0 } }, \
414-
{ 1259, {"relchecks"}, 21, -1,2, 16, 0, -1, -1, true, 'p', 's', true, false, false, true, 0, { 0 } }, \
415-
{ 1259, {"relhasoids"}, 16, -1,1, 17, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
416-
{ 1259, {"relhaspkey"}, 16, -1,1, 18, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
417-
{ 1259, {"relhasrules"}, 16, -1,1, 19, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
418-
{ 1259, {"relhastriggers"},16, -1,1, 20, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
419-
{ 1259, {"relhassubclass"},16, -1,1, 21, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
420-
{ 1259, {"relfrozenxid"}, 28, -1,4, 22, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \
421-
{ 1259, {"relacl"}, 1034, -1, -1, 23, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0, { 0 } }, \
422-
{ 1259, {"reloptions"}, 1009, -1, -1, 24, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0, { 0 } }
412+
{ 1259, {"relistemp"}, 16, -1,1, 14, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
413+
{ 1259, {"relkind"}, 18, -1,1, 15, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
414+
{ 1259, {"relnatts"}, 21, -1,2, 16, 0, -1, -1, true, 'p', 's', true, false, false, true, 0, { 0 } }, \
415+
{ 1259, {"relchecks"}, 21, -1,2, 17, 0, -1, -1, true, 'p', 's', true, false, false, true, 0, { 0 } }, \
416+
{ 1259, {"relhasoids"}, 16, -1,1, 18, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
417+
{ 1259, {"relhaspkey"}, 16, -1,1, 19, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
418+
{ 1259, {"relhasrules"}, 16, -1,1, 20, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
419+
{ 1259, {"relhastriggers"},16, -1,1, 21, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
420+
{ 1259, {"relhassubclass"},16, -1,1, 22, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0, { 0 } }, \
421+
{ 1259, {"relfrozenxid"}, 28, -1,4, 23, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0, { 0 } }, \
422+
{ 1259, {"relacl"}, 1034, -1, -1, 24, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0, { 0 } }, \
423+
{ 1259, {"reloptions"}, 1009, -1, -1, 25, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0, { 0 } }
423424

424425
DATA(insert (1259relname19-1NAMEDATALEN10-1-1fpctfft0_null_));
425426
DATA(insert (1259relnamespace26-1420-1-1tpitfft0_null_));
@@ -434,17 +435,18 @@ DATA(insert ( 1259 reltoastrelid26 -1 4 10 0 -1 -1 t p i t f f t 0 _null_));
434435
DATA(insert (1259reltoastidxid26-14110-1-1tpitfft0_null_));
435436
DATA(insert (1259relhasindex16-11120-1-1tpctfft0_null_));
436437
DATA(insert (1259relisshared16-11130-1-1tpctfft0_null_));
437-
DATA(insert (1259relkind18-11140-1-1tpctfft0_null_));
438-
DATA(insert (1259relnatts21-12150-1-1tpstfft0_null_));
439-
DATA(insert (1259relchecks21-12160-1-1tpstfft0_null_));
440-
DATA(insert (1259relhasoids16-11170-1-1tpctfft0_null_));
441-
DATA(insert (1259relhaspkey16-11180-1-1tpctfft0_null_));
442-
DATA(insert (1259relhasrules16-11190-1-1tpctfft0_null_));
443-
DATA(insert (1259relhastriggers16-11200-1-1tpctfft0_null_));
444-
DATA(insert (1259relhassubclass16-11210-1-1tpctfft0_null_));
445-
DATA(insert (1259relfrozenxid28-14220-1-1tpitfft0_null_));
446-
DATA(insert (1259relacl1034-1-1231-1-1fxiffft0_null_));
447-
DATA(insert (1259reloptions1009-1-1241-1-1fxiffft0_null_));
438+
DATA(insert (1259relistemp16-11140-1-1tpctfft0_null_));
439+
DATA(insert (1259relkind18-11150-1-1tpctfft0_null_));
440+
DATA(insert (1259relnatts21-12160-1-1tpstfft0_null_));
441+
DATA(insert (1259relchecks21-12170-1-1tpstfft0_null_));
442+
DATA(insert (1259relhasoids16-11180-1-1tpctfft0_null_));
443+
DATA(insert (1259relhaspkey16-11190-1-1tpctfft0_null_));
444+
DATA(insert (1259relhasrules16-11200-1-1tpctfft0_null_));
445+
DATA(insert (1259relhastriggers16-11210-1-1tpctfft0_null_));
446+
DATA(insert (1259relhassubclass16-11220-1-1tpctfft0_null_));
447+
DATA(insert (1259relfrozenxid28-14230-1-1tpitfft0_null_));
448+
DATA(insert (1259relacl1034-1-1241-1-1fxiffft0_null_));
449+
DATA(insert (1259reloptions1009-1-1251-1-1fxiffft0_null_));
448450
DATA(insert (1259ctid2706-10-1-1fpstfft0_null_));
449451
DATA(insert (1259oid2604-20-1-1tpitfft0_null_));
450452
DATA(insert (1259xmin2804-30-1-1tpitfft0_null_));

‎src/include/catalog/pg_class.h‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.112 2009/01/22 20:16:09 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.113 2009/03/31 17:59:56 tgl Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -43,6 +43,7 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP
4343
Oidreltoastidxid;/* if toast table, OID of chunk_id index */
4444
boolrelhasindex;/* T if has (or has had) any indexes */
4545
boolrelisshared;/* T if shared across databases */
46+
boolrelistemp;/* T if temporary relation */
4647
charrelkind;/* see RELKIND_xxx constants below */
4748
int2relnatts;/* number of user attributes */
4849

@@ -85,7 +86,7 @@ typedef FormData_pg_class *Form_pg_class;
8586
* ----------------
8687
*/
8788

88-
#defineNatts_pg_class24
89+
#defineNatts_pg_class25
8990
#defineAnum_pg_class_relname1
9091
#defineAnum_pg_class_relnamespace2
9192
#defineAnum_pg_class_reltype3
@@ -99,17 +100,18 @@ typedef FormData_pg_class *Form_pg_class;
99100
#defineAnum_pg_class_reltoastidxid11
100101
#defineAnum_pg_class_relhasindex12
101102
#defineAnum_pg_class_relisshared13
102-
#defineAnum_pg_class_relkind14
103-
#defineAnum_pg_class_relnatts15
104-
#defineAnum_pg_class_relchecks16
105-
#defineAnum_pg_class_relhasoids17
106-
#defineAnum_pg_class_relhaspkey18
107-
#defineAnum_pg_class_relhasrules19
108-
#defineAnum_pg_class_relhastriggers20
109-
#defineAnum_pg_class_relhassubclass21
110-
#defineAnum_pg_class_relfrozenxid22
111-
#defineAnum_pg_class_relacl23
112-
#defineAnum_pg_class_reloptions24
103+
#defineAnum_pg_class_relistemp14
104+
#defineAnum_pg_class_relkind15
105+
#defineAnum_pg_class_relnatts16
106+
#defineAnum_pg_class_relchecks17
107+
#defineAnum_pg_class_relhasoids18
108+
#defineAnum_pg_class_relhaspkey19
109+
#defineAnum_pg_class_relhasrules20
110+
#defineAnum_pg_class_relhastriggers21
111+
#defineAnum_pg_class_relhassubclass22
112+
#defineAnum_pg_class_relfrozenxid23
113+
#defineAnum_pg_class_relacl24
114+
#defineAnum_pg_class_reloptions25
113115

114116
/* ----------------
115117
*initial contents of pg_class
@@ -121,13 +123,13 @@ typedef FormData_pg_class *Form_pg_class;
121123
*/
122124

123125
/* Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId */
124-
DATA(insertOID=1247 (pg_typePGNSP71PGUID0124700000ffr280tffff3_null__null_ ));
126+
DATA(insertOID=1247 (pg_typePGNSP71PGUID0124700000fffr280tffff3_null__null_ ));
125127
DESCR("");
126-
DATA(insertOID=1249 (pg_attributePGNSP75PGUID0124900000ffr180fffff3_null__null_ ));
128+
DATA(insertOID=1249 (pg_attributePGNSP75PGUID0124900000fffr180fffff3_null__null_ ));
127129
DESCR("");
128-
DATA(insertOID=1255 (pg_procPGNSP81PGUID0125500000ffr250tffff3_null__null_ ));
130+
DATA(insertOID=1255 (pg_procPGNSP81PGUID0125500000fffr250tffff3_null__null_ ));
129131
DESCR("");
130-
DATA(insertOID=1259 (pg_classPGNSP83PGUID0125900000ffr240tffff3_null__null_ ));
132+
DATA(insertOID=1259 (pg_classPGNSP83PGUID0125900000fffr250tffff3_null__null_ ));
131133
DESCR("");
132134

133135
#defineRELKIND_INDEX 'i'/* secondary index */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp