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

Commitabc624f

Browse files
author
Nikita Glukhov
committed
Add oldRefObjectSubId, pTotalInternalRefCount parameters to changeDependencyFor()
1 parent7ac1e2e commitabc624f

File tree

6 files changed

+31
-12
lines changed

6 files changed

+31
-12
lines changed

‎src/backend/catalog/pg_depend.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,11 @@ deleteDependencyRecordsForClass(Oid classId, Oid objectId, int32 objectSubId,
304304
*/
305305
long
306306
changeDependencyFor(OidclassId,OidobjectId,
307-
OidrefClassId,OidoldRefObjectId,
308-
OidnewRefObjectId)
307+
OidrefClassId,OidoldRefObjectId,int32oldRefObjectSubId,
308+
OidnewRefObjectId,long*pTotalInternalRefCount)
309309
{
310310
longcount=0;
311+
longtotalInternalRefCount=0;
311312
RelationdepRel;
312313
ScanKeyDatakey[2];
313314
SysScanDescscan;
@@ -325,7 +326,7 @@ changeDependencyFor(Oid classId, Oid objectId,
325326
*/
326327
objAddr.classId=refClassId;
327328
objAddr.objectId=oldRefObjectId;
328-
objAddr.objectSubId=0;
329+
objAddr.objectSubId=oldRefObjectSubId;
329330

330331
if (isObjectPinned(&objAddr,depRel))
331332
ereport(ERROR,
@@ -337,9 +338,15 @@ changeDependencyFor(Oid classId, Oid objectId,
337338
* We can handle adding a dependency on something pinned, though, since
338339
* that just means deleting the dependency entry.
339340
*/
340-
objAddr.objectId=newRefObjectId;
341+
if (OidIsValid(newRefObjectId))
342+
{
343+
objAddr.objectId=newRefObjectId;
344+
objAddr.objectSubId=0;
341345

342-
newIsPinned=isObjectPinned(&objAddr,depRel);
346+
newIsPinned=isObjectPinned(&objAddr,depRel);
347+
}
348+
else
349+
newIsPinned= true;
343350

344351
/* Now search for dependency records */
345352
ScanKeyInit(&key[0],
@@ -359,7 +366,9 @@ changeDependencyFor(Oid classId, Oid objectId,
359366
Form_pg_dependdepform= (Form_pg_depend)GETSTRUCT(tup);
360367

361368
if (depform->refclassid==refClassId&&
362-
depform->refobjid==oldRefObjectId)
369+
depform->refobjid==oldRefObjectId&&
370+
(oldRefObjectSubId==0||
371+
depform->refobjsubid==oldRefObjectSubId))
363372
{
364373
if (newIsPinned)
365374
CatalogTupleDelete(depRel,&tup->t_self);
@@ -370,6 +379,7 @@ changeDependencyFor(Oid classId, Oid objectId,
370379
depform= (Form_pg_depend)GETSTRUCT(tup);
371380

372381
depform->refobjid=newRefObjectId;
382+
depform->refobjsubid=0;
373383

374384
CatalogTupleUpdate(depRel,&tup->t_self,tup);
375385

@@ -378,12 +388,18 @@ changeDependencyFor(Oid classId, Oid objectId,
378388

379389
count++;
380390
}
391+
392+
if (depform->deptype==DEPENDENCY_INTERNAL)
393+
totalInternalRefCount++;
381394
}
382395

383396
systable_endscan(scan);
384397

385398
heap_close(depRel,RowExclusiveLock);
386399

400+
if (pTotalInternalRefCount)
401+
*pTotalInternalRefCount=totalInternalRefCount;
402+
387403
returncount;
388404
}
389405

‎src/backend/commands/alter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
751751

752752
/* update dependencies to point to the new schema */
753753
changeDependencyFor(classId,objid,
754-
NamespaceRelationId,oldNspOid,nspOid);
754+
NamespaceRelationId,oldNspOid,0,nspOid,NULL);
755755

756756
InvokeObjectPostAlterHook(classId,objid,0);
757757

‎src/backend/commands/extension.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2842,7 +2842,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
28422842

28432843
/* update dependencies to point to the new schema */
28442844
changeDependencyFor(ExtensionRelationId,extensionOid,
2845-
NamespaceRelationId,oldNspOid,nspOid);
2845+
NamespaceRelationId,oldNspOid,0,nspOid,NULL);
28462846

28472847
InvokeObjectPostAlterHook(ExtensionRelationId,extensionOid,0);
28482848

‎src/backend/commands/tablecmds.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12914,7 +12914,9 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
1291412914
relOid,
1291512915
NamespaceRelationId,
1291612916
oldNspOid,
12917-
newNspOid)!=1)
12917+
0,
12918+
newNspOid,
12919+
NULL)!=1)
1291812920
elog(ERROR,"failed to change schema dependency for relation \"%s\"",
1291912921
NameStr(classForm->relname));
1292012922
}

‎src/backend/commands/typecmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3603,7 +3603,8 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
36033603
(isCompositeType||typform->typtype!=TYPTYPE_COMPOSITE)&&
36043604
!isImplicitArray)
36053605
if (changeDependencyFor(TypeRelationId,typeOid,
3606-
NamespaceRelationId,oldNspOid,nspOid)!=1)
3606+
NamespaceRelationId,oldNspOid,0,
3607+
nspOid,NULL)!=1)
36073608
elog(ERROR,"failed to change schema dependency for type %s",
36083609
format_type_be(typeOid));
36093610

‎src/include/catalog/dependency.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ extern long deleteDependencyRecordsForClass(Oid classId, Oid objectId,
235235
OidrefclassId,chardeptype);
236236

237237
externlongchangeDependencyFor(OidclassId,OidobjectId,
238-
OidrefClassId,OidoldRefObjectId,
239-
OidnewRefObjectId);
238+
OidrefClassId,OidoldRefObjectId,int32oldRefObjectSubId,
239+
OidnewRefObjectId,long*totalRefCount);
240240

241241
externOidgetExtensionOfObject(OidclassId,OidobjectId);
242242

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp