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

Commitc328b6d

Browse files
committed
Replace pg_attribute.attisinherited with attislocal and attinhcount
columns, to allow more correct behavior in multiple-inheritance cases.Patch by Alvaro Herrera, review by Tom Lane.
1 parent634e440 commitc328b6d

File tree

21 files changed

+583
-298
lines changed

21 files changed

+583
-298
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.60 2002/09/18 21:35:20 tgl Exp $
3+
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.61 2002/09/22 19:42:50 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -822,12 +822,22 @@
822822
</row>
823823

824824
<row>
825-
<entry>attisinherited</entry>
825+
<entry>attislocal</entry>
826826
<entry><type>bool</type></entry>
827827
<entry></entry>
828828
<entry>
829-
This column is inherited from some other relation. An inherited
830-
column cannot be dropped nor renamed.
829+
This column is defined locally in the relation. Note that a column may
830+
be locally defined and inherited simultaneously.
831+
</entry>
832+
</row>
833+
834+
<row>
835+
<entry>attinhcount</entry>
836+
<entry><type>int4</type></entry>
837+
<entry></entry>
838+
<entry>
839+
The number of direct ancestors this column has. A column with a
840+
nonzero number of ancestors cannot be dropped nor renamed.
831841
</entry>
832842
</row>
833843

@@ -1213,8 +1223,8 @@
12131223
<entry></entry>
12141224
<entry>
12151225
'c' = check constraint,
1216-
'f' = foreign key constraint,
1217-
'p' = primary key constraint,
1226+
'f' = foreign key constraint,
1227+
'p' = primary key constraint,
12181228
'u' = unique constraint
12191229
</entry>
12201230
</row>
@@ -3316,7 +3326,7 @@
33163326
when storing a value of this type. It applies to storage on
33173327
disk as well as most representations of the value inside
33183328
<productname>PostgreSQL</>.
3319-
When multiple values are stored consecutively, such
3329+
When multiple values are stored consecutively, such
33203330
as in the representation of a complete row on disk, padding is
33213331
inserted before a datum of this type so that it begins on the
33223332
specified boundary. The alignment reference is the beginning

‎src/backend/access/common/tupdesc.c

Lines changed: 8 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/access/common/tupdesc.c,v 1.89 2002/09/04 20:31:09 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.90 2002/09/22 19:42:50 tgl Exp $
1212
*
1313
* NOTES
1414
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -271,7 +271,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
271271
return false;
272272
if (attr1->attisdropped!=attr2->attisdropped)
273273
return false;
274-
if (attr1->attisinherited!=attr2->attisinherited)
274+
if (attr1->attislocal!=attr2->attislocal)
275+
return false;
276+
if (attr1->attinhcount!=attr2->attinhcount)
275277
return false;
276278
}
277279
if (tupdesc1->constr!=NULL)
@@ -396,7 +398,8 @@ TupleDescInitEntry(TupleDesc desc,
396398
att->attnotnull= false;
397399
att->atthasdef= false;
398400
att->attisdropped= false;
399-
att->attisinherited= false;
401+
att->attislocal= true;
402+
att->attinhcount=0;
400403

401404
tuple=SearchSysCache(TYPEOID,
402405
ObjectIdGetDatum(oidtypeid),
@@ -543,7 +546,8 @@ BuildDescForRelation(List *schema)
543546
desc->attrs[attnum-1]->atthasdef= true;
544547
}
545548

546-
desc->attrs[attnum-1]->attisinherited=entry->is_inherited;
549+
desc->attrs[attnum-1]->attislocal=entry->is_local;
550+
desc->attrs[attnum-1]->attinhcount=entry->inhcount;
547551
}
548552

549553
if (constr->has_not_null||ndef>0)

‎src/backend/bootstrap/bootstrap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.141 2002/09/04 20:31:13 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.142 2002/09/22 19:42:50 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -587,7 +587,7 @@ DefineAttr(char *name, char *type, int attnum)
587587

588588
namestrcpy(&attrtypes[attnum]->attname,name);
589589
elog(DEBUG3,"column %s %s",NameStr(attrtypes[attnum]->attname),type);
590-
attrtypes[attnum]->attnum=1+attnum;/* fillatt */
590+
attrtypes[attnum]->attnum=attnum+1;/* fillatt */
591591

592592
typeoid=gettype(type);
593593

@@ -640,6 +640,7 @@ DefineAttr(char *name, char *type, int attnum)
640640
}
641641
attrtypes[attnum]->attcacheoff=-1;
642642
attrtypes[attnum]->atttypmod=-1;
643+
attrtypes[attnum]->attislocal= true;
643644

644645
/*
645646
* Mark as "not null" if type is fixed-width and prior columns are

‎src/backend/catalog/heap.c

Lines changed: 8 additions & 8 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.230 2002/09/2200:37:09 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.231 2002/09/2219:42:50 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -97,37 +97,37 @@ static void RemoveStatistics(Relation rel);
9797
staticFormData_pg_attributea1= {
9898
0, {"ctid"},TIDOID,0,sizeof(ItemPointerData),
9999
SelfItemPointerAttributeNumber,0,-1,-1,
100-
false,'p', false,'i', true, false, false
100+
false,'p', false,'i', true, false, false, true,0
101101
};
102102

103103
staticFormData_pg_attributea2= {
104104
0, {"oid"},OIDOID,0,sizeof(Oid),
105105
ObjectIdAttributeNumber,0,-1,-1,
106-
true,'p', false,'i', true, false, false
106+
true,'p', false,'i', true, false, false, true,0
107107
};
108108

109109
staticFormData_pg_attributea3= {
110110
0, {"xmin"},XIDOID,0,sizeof(TransactionId),
111111
MinTransactionIdAttributeNumber,0,-1,-1,
112-
true,'p', false,'i', true, false, false
112+
true,'p', false,'i', true, false, false, true,0
113113
};
114114

115115
staticFormData_pg_attributea4= {
116116
0, {"cmin"},CIDOID,0,sizeof(CommandId),
117117
MinCommandIdAttributeNumber,0,-1,-1,
118-
true,'p', false,'i', true, false, false
118+
true,'p', false,'i', true, false, false, true,0
119119
};
120120

121121
staticFormData_pg_attributea5= {
122122
0, {"xmax"},XIDOID,0,sizeof(TransactionId),
123123
MaxTransactionIdAttributeNumber,0,-1,-1,
124-
true,'p', false,'i', true, false, false
124+
true,'p', false,'i', true, false, false, true,0
125125
};
126126

127127
staticFormData_pg_attributea6= {
128128
0, {"cmax"},CIDOID,0,sizeof(CommandId),
129129
MaxCommandIdAttributeNumber,0,-1,-1,
130-
true,'p', false,'i', true, false, false
130+
true,'p', false,'i', true, false, false, true,0
131131
};
132132

133133
/*
@@ -139,7 +139,7 @@ static FormData_pg_attribute a6 = {
139139
staticFormData_pg_attributea7= {
140140
0, {"tableoid"},OIDOID,0,sizeof(Oid),
141141
TableOidAttributeNumber,0,-1,-1,
142-
true,'p', false,'i', true, false, false
142+
true,'p', false,'i', true, false, false, true,0
143143
};
144144

145145
staticForm_pg_attributeSysAtt[]= {&a1,&a2,&a3,&a4,&a5,&a6,&a7};

‎src/backend/catalog/index.c

Lines changed: 6 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/index.c,v 1.197 2002/09/2200:37:09 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.198 2002/09/2219:42:50 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -165,10 +165,11 @@ BuildFuncTupleDesc(Oid funcOid,
165165
funcTupDesc->attrs[0]->atttypid=keyType;
166166
funcTupDesc->attrs[0]->attlen=typeTup->typlen;
167167
funcTupDesc->attrs[0]->attbyval=typeTup->typbyval;
168-
funcTupDesc->attrs[0]->attcacheoff=-1;
169-
funcTupDesc->attrs[0]->atttypmod=-1;
170168
funcTupDesc->attrs[0]->attstorage=typeTup->typstorage;
171169
funcTupDesc->attrs[0]->attalign=typeTup->typalign;
170+
funcTupDesc->attrs[0]->attcacheoff=-1;
171+
funcTupDesc->attrs[0]->atttypmod=-1;
172+
funcTupDesc->attrs[0]->attislocal= true;
172173

173174
ReleaseSysCache(tuple);
174175

@@ -259,7 +260,8 @@ ConstructTupleDescriptor(Relation heapRelation,
259260
to->attcacheoff=-1;
260261
to->attnotnull= false;
261262
to->atthasdef= false;
262-
to->attisinherited= false;
263+
to->attislocal= true;
264+
to->attinhcount=0;
263265

264266
/*
265267
* We do not yet have the correct relation OID for the index, so

‎src/backend/commands/sequence.c

Lines changed: 3 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/commands/sequence.c,v 1.87 2002/09/04 20:31:15 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.88 2002/09/22 19:42:50 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -127,7 +127,8 @@ DefineSequence(CreateSeqStmt *seq)
127127

128128
coldef=makeNode(ColumnDef);
129129
coldef->typename=typnam;
130-
coldef->is_inherited= false;
130+
coldef->inhcount=0;
131+
coldef->is_local= true;
131132
coldef->is_not_null= true;
132133
coldef->raw_default=NULL;
133134
coldef->cooked_default=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp