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

Commit5af19e4

Browse files
committed
Add more dependency insertions --- this completes the basic pg_depend
functionality. Of note: dropping a table that has a SERIAL columndefined now drops the associated sequence automatically.
1 parentcdebcad commit5af19e4

File tree

19 files changed

+402
-90
lines changed

19 files changed

+402
-90
lines changed

‎doc/src/sgml/release.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.140 2002/07/12 18:43:12 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.141 2002/07/16 22:12:18 tgl Exp $
33
-->
44

55
<appendix id="release">
@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
2424
worries about funny characters.
2525
-->
2626
<literallayout><![CDATA[
27+
Sequences created by SERIAL column definitions now auto-drop with the column
2728
Most forms of DROP now support RESTRICT and CASCADE options
2829
Recursive SQL functions can be defined
2930
User-defined procedural languages can register a validator function to check new functions as they are created

‎src/backend/catalog/heap.c

Lines changed: 25 additions & 11 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.208 2002/07/1605:53:33 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.209 2002/07/1622:12:18 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',false, false
100+
false,'p', false,'i',true, false
101101
};
102102

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

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

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

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

127127
staticFormData_pg_attributea6= {
128128
0, {"cmax"},CIDOID,0,sizeof(CommandId),
129129
MaxCommandIdAttributeNumber,0,-1,-1,
130-
true,'p', false,'i',false, false
130+
true,'p', false,'i',true, false
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',false, false
142+
true,'p', false,'i',true, false
143143
};
144144

145145
staticForm_pg_attributeSysAtt[]= {&a1,&a2,&a3,&a4,&a5,&a6,&a7};
@@ -416,6 +416,8 @@ AddNewAttributeTuples(Oid new_rel_oid,
416416
boolhasindex;
417417
Relationidescs[Num_pg_attr_indices];
418418
intnatts=tupdesc->natts;
419+
ObjectAddressmyself,
420+
referenced;
419421

420422
/*
421423
* open pg_attribute
@@ -430,7 +432,8 @@ AddNewAttributeTuples(Oid new_rel_oid,
430432
CatalogOpenIndices(Num_pg_attr_indices,Name_pg_attr_indices,idescs);
431433

432434
/*
433-
* first we add the user attributes..
435+
* First we add the user attributes. This is also a convenient place
436+
* to add dependencies on their datatypes.
434437
*/
435438
dpp=tupdesc->attrs;
436439
for (i=0;i<natts;i++)
@@ -451,11 +454,22 @@ AddNewAttributeTuples(Oid new_rel_oid,
451454
CatalogIndexInsert(idescs,Num_pg_attr_indices,rel,tup);
452455

453456
heap_freetuple(tup);
457+
458+
myself.classId=RelOid_pg_class;
459+
myself.objectId=new_rel_oid;
460+
myself.objectSubId=i+1;
461+
referenced.classId=RelOid_pg_type;
462+
referenced.objectId= (*dpp)->atttypid;
463+
referenced.objectSubId=0;
464+
recordDependencyOn(&myself,&referenced,DEPENDENCY_NORMAL);
465+
454466
dpp++;
455467
}
456468

457469
/*
458-
* next we add the system attributes. Skip OID if rel has no OIDs.
470+
* Next we add the system attributes. Skip OID if rel has no OIDs.
471+
* Skip all for a view. We don't bother with making datatype
472+
* dependencies here, since presumably all these types are pinned.
459473
*/
460474
if (relkind!=RELKIND_VIEW)
461475
{
@@ -493,7 +507,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
493507
}
494508

495509
/*
496-
*close pg_attribute indices
510+
*clean up
497511
*/
498512
if (hasindex)
499513
CatalogCloseIndices(Num_pg_attr_indices,idescs);

‎src/backend/catalog/pg_aggregate.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.49 2002/06/20 20:29:26 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.50 2002/07/16 22:12:18 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include"postgres.h"
1616

1717
#include"access/heapam.h"
1818
#include"catalog/catname.h"
19+
#include"catalog/dependency.h"
1920
#include"catalog/indexing.h"
2021
#include"catalog/namespace.h"
2122
#include"catalog/pg_aggregate.h"
@@ -53,6 +54,8 @@ AggregateCreate(const char *aggName,
5354
OidprocOid;
5455
TupleDesctupDesc;
5556
inti;
57+
ObjectAddressmyself,
58+
referenced;
5659

5760
/* sanity checks */
5861
if (!aggName)
@@ -187,4 +190,29 @@ AggregateCreate(const char *aggName,
187190
}
188191

189192
heap_close(aggdesc,RowExclusiveLock);
193+
194+
/*
195+
* Create dependencies for the aggregate (above and beyond those
196+
* already made by ProcedureCreate). Note: we don't need an explicit
197+
* dependency on aggTransType since we depend on it indirectly through
198+
* transfn.
199+
*/
200+
myself.classId=RelOid_pg_proc;
201+
myself.objectId=procOid;
202+
myself.objectSubId=0;
203+
204+
/* Depends on transition function */
205+
referenced.classId=RelOid_pg_proc;
206+
referenced.objectId=transfn;
207+
referenced.objectSubId=0;
208+
recordDependencyOn(&myself,&referenced,DEPENDENCY_NORMAL);
209+
210+
/* Depends on final function, if any */
211+
if (OidIsValid(finalfn))
212+
{
213+
referenced.classId=RelOid_pg_proc;
214+
referenced.objectId=finalfn;
215+
referenced.objectSubId=0;
216+
recordDependencyOn(&myself,&referenced,DEPENDENCY_NORMAL);
217+
}
190218
}

‎src/backend/catalog/pg_constraint.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.2 2002/07/1605:53:33 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.3 2002/07/1622:12:18 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -198,17 +198,11 @@ CreateConstraintEntry(const char *constraintName,
198198
if (OidIsValid(foreignRelId))
199199
{
200200
/*
201-
* Register dependency from constraint to foreign relation,
201+
* Registernormaldependency from constraint to foreign relation,
202202
* or to specific column(s) if any are mentioned.
203-
*
204-
* In normal case of two separate relations, make this a NORMAL
205-
* dependency (so dropping the FK table would require CASCADE).
206-
* However, for a self-reference just make it AUTO.
207203
*/
208-
DependencyTypedeptype;
209204
ObjectAddressrelobject;
210205

211-
deptype= (foreignRelId==relId) ?DEPENDENCY_AUTO :DEPENDENCY_NORMAL;
212206
relobject.classId=RelOid_pg_class;
213207
relobject.objectId=foreignRelId;
214208
if (foreignNKeys>0)
@@ -217,14 +211,14 @@ CreateConstraintEntry(const char *constraintName,
217211
{
218212
relobject.objectSubId=foreignKey[i];
219213

220-
recordDependencyOn(&conobject,&relobject,deptype);
214+
recordDependencyOn(&conobject,&relobject,DEPENDENCY_NORMAL);
221215
}
222216
}
223217
else
224218
{
225219
relobject.objectSubId=0;
226220

227-
recordDependencyOn(&conobject,&relobject,deptype);
221+
recordDependencyOn(&conobject,&relobject,DEPENDENCY_NORMAL);
228222
}
229223
}
230224

‎src/backend/catalog/pg_depend.c

Lines changed: 38 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/pg_depend.c,v 1.2 2002/07/1605:53:33 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_depend.c,v 1.3 2002/07/1622:12:18 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -121,6 +121,43 @@ recordMultipleDependencies(const ObjectAddress *depender,
121121
heap_close(dependDesc,RowExclusiveLock);
122122
}
123123

124+
/*
125+
* deleteDependencyRecordsFor -- delete all records with given depender
126+
* classId/objectId.
127+
*
128+
* This is used when redefining an existing object. Links leading to the
129+
* object do not change, and links leading from it will be recreated
130+
* (possibly with some differences from before).
131+
*/
132+
void
133+
deleteDependencyRecordsFor(OidclassId,OidobjectId)
134+
{
135+
RelationdepRel;
136+
ScanKeyDatakey[2];
137+
SysScanDescscan;
138+
HeapTupletup;
139+
140+
depRel=heap_openr(DependRelationName,RowExclusiveLock);
141+
142+
ScanKeyEntryInitialize(&key[0],0x0,
143+
Anum_pg_depend_classid,F_OIDEQ,
144+
ObjectIdGetDatum(classId));
145+
ScanKeyEntryInitialize(&key[1],0x0,
146+
Anum_pg_depend_objid,F_OIDEQ,
147+
ObjectIdGetDatum(objectId));
148+
149+
scan=systable_beginscan(depRel,DependDependerIndex, true,
150+
SnapshotNow,2,key);
151+
152+
while (HeapTupleIsValid(tup=systable_getnext(scan)))
153+
{
154+
simple_heap_delete(depRel,&tup->t_self);
155+
}
156+
157+
systable_endscan(scan);
158+
159+
heap_close(depRel,RowExclusiveLock);
160+
}
124161

125162
/*
126163
* isObjectPinned()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp