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

Commit154f26f

Browse files
committed
RemoveAttrDefaultById() neglected to obtain exclusive lock on the
relation being modified. In most paths of control we'd already havesuch a lock, but if we were dropping the default due to a cascadeddelete of some function it depended on, maybe not.
1 parent21cf6b2 commit154f26f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎src/backend/catalog/heap.c

Lines changed: 14 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/heap.c,v 1.215 2002/08/0218:15:05 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.216 2002/08/0221:54:34 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1027,6 +1027,7 @@ RemoveAttrDefaultById(Oid attrdefId)
10271027
{
10281028
Relationattrdef_rel;
10291029
Relationattr_rel;
1030+
Relationmyrel;
10301031
ScanKeyDatascankeys[1];
10311032
SysScanDescscan;
10321033
HeapTupletuple;
@@ -1036,6 +1037,7 @@ RemoveAttrDefaultById(Oid attrdefId)
10361037
/* Grab an appropriate lock on the pg_attrdef relation */
10371038
attrdef_rel=heap_openr(AttrDefaultRelationName,RowExclusiveLock);
10381039

1040+
/* Find the pg_attrdef tuple */
10391041
ScanKeyEntryInitialize(&scankeys[0],0x0,
10401042
ObjectIdAttributeNumber,F_OIDEQ,
10411043
ObjectIdGetDatum(attrdefId));
@@ -1051,6 +1053,10 @@ RemoveAttrDefaultById(Oid attrdefId)
10511053
myrelid= ((Form_pg_attrdef)GETSTRUCT(tuple))->adrelid;
10521054
myattnum= ((Form_pg_attrdef)GETSTRUCT(tuple))->adnum;
10531055

1056+
/* Get an exclusive lock on the relation owning the attribute */
1057+
myrel=heap_open(myrelid,AccessExclusiveLock);
1058+
1059+
/* Now we can delete the pg_attrdef row */
10541060
simple_heap_delete(attrdef_rel,&tuple->t_self);
10551061

10561062
systable_endscan(scan);
@@ -1081,7 +1087,14 @@ RemoveAttrDefaultById(Oid attrdefId)
10811087
CatalogCloseIndices(Num_pg_attr_indices,idescs);
10821088
}
10831089

1090+
/*
1091+
* Our update of the pg_attribute row will force a relcache rebuild,
1092+
* so there's nothing else to do here.
1093+
*/
10841094
heap_close(attr_rel,RowExclusiveLock);
1095+
1096+
/* Keep lock on attribute's rel until end of xact */
1097+
heap_close(myrel,NoLock);
10851098
}
10861099

10871100
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp