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

Commite2d156f

Browse files
committed
Add attisinherited column to pg_attribute; use it to guard against
column additions, deletions, and renames that would let a child tableget out of sync with its parent. Patch by Alvaro Herrera, with somekibitzing by Tom Lane.
1 parent96fd719 commite2d156f

File tree

18 files changed

+492
-330
lines changed

18 files changed

+492
-330
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 11 additions & 1 deletion
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.55 2002/08/28 15:02:55 tgl Exp $
3+
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.56 2002/08/30 19:23:18 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -821,6 +821,16 @@
821821
</entry>
822822
</row>
823823

824+
<row>
825+
<entry>attisinherited</entry>
826+
<entry><type>bool</type></entry>
827+
<entry></entry>
828+
<entry>
829+
This column is inherited from some other relation. An inherited
830+
column cannot be dropped nor renamed.
831+
</entry>
832+
</row>
833+
824834
</tbody>
825835
</tgroup>
826836
</table>

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

Lines changed: 12 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/common/tupdesc.c,v 1.86 2002/08/29 00:17:02 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.87 2002/08/30 19:23:18 tgl Exp $
1212
*
1313
* NOTES
1414
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -231,6 +231,9 @@ FreeTupleDesc(TupleDesc tupdesc)
231231

232232
}
233233

234+
/*
235+
* Compare two TupleDesc structures for logical equality
236+
*/
234237
bool
235238
equalTupleDescs(TupleDesctupdesc1,TupleDesctupdesc2)
236239
{
@@ -264,8 +267,12 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
264267
return false;
265268
if (attr1->attnotnull!=attr2->attnotnull)
266269
return false;
270+
if (attr1->atthasdef!=attr2->atthasdef)
271+
return false;
267272
if (attr1->attisdropped!=attr2->attisdropped)
268273
return false;
274+
if (attr1->attisinherited!=attr2->attisinherited)
275+
return false;
269276
}
270277
if (tupdesc1->constr!=NULL)
271278
{
@@ -389,6 +396,7 @@ TupleDescInitEntry(TupleDesc desc,
389396
att->attnotnull= false;
390397
att->atthasdef= false;
391398
att->attisdropped= false;
399+
att->attisinherited= false;
392400

393401
tuple=SearchSysCache(TYPEOID,
394402
ObjectIdGetDatum(oidtypeid),
@@ -514,7 +522,7 @@ BuildDescForRelation(List *schema)
514522
typenameTypeId(entry->typename),
515523
atttypmod,attdim,attisset);
516524

517-
/*This is for constraints */
525+
/*Fill in additional stuff not handled by TupleDescInitEntry */
518526
if (entry->is_not_null)
519527
constr->has_not_null= true;
520528
desc->attrs[attnum-1]->attnotnull=entry->is_not_null;
@@ -533,7 +541,9 @@ BuildDescForRelation(List *schema)
533541
desc->attrs[attnum-1]->atthasdef= true;
534542
}
535543

544+
desc->attrs[attnum-1]->attisinherited=entry->is_inherited;
536545
}
546+
537547
if (constr->has_not_null||ndef>0)
538548
{
539549
desc->constr=constr;

‎src/backend/catalog/index.c

Lines changed: 2 additions & 1 deletion
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.191 2002/08/29 15:56:19 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.192 2002/08/30 19:23:18 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -259,6 +259,7 @@ ConstructTupleDescriptor(Relation heapRelation,
259259
to->attcacheoff=-1;
260260
to->attnotnull= false;
261261
to->atthasdef= false;
262+
to->attisinherited= false;
262263

263264
/*
264265
* We do not yet have the correct relation OID for the index, so

‎src/backend/commands/sequence.c

Lines changed: 2 additions & 1 deletion
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.84 2002/08/06 02:36:34 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.85 2002/08/30 19:23:19 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -127,6 +127,7 @@ DefineSequence(CreateSeqStmt *seq)
127127

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp