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

Commitf7cffbb

Browse files
committed
Tweak dependency code to suppress NOTICEs generated by new method for
cleaning out temp namespaces. We don't really want the server log to becluttered with 'Drop cascades to table foo' every time someone uses atemp table...
1 parent0c693b4 commitf7cffbb

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

‎src/backend/catalog/dependency.c

Lines changed: 27 additions & 20 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/catalog/dependency.c,v 1.22 2003/02/16 02:30:37 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.23 2003/03/06 22:54:49 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -97,12 +97,14 @@ static void findAutoDeletableObjects(const ObjectAddress *object,
9797
RelationdepRel);
9898
staticboolrecursiveDeletion(constObjectAddress*object,
9999
DropBehaviorbehavior,
100+
intmsglevel,
100101
constObjectAddress*callingObject,
101102
ObjectAddresses*oktodelete,
102103
RelationdepRel);
103104
staticbooldeleteDependentObjects(constObjectAddress*object,
104105
constchar*objDescription,
105106
DropBehaviorbehavior,
107+
intmsglevel,
106108
ObjectAddresses*oktodelete,
107109
RelationdepRel);
108110
staticvoiddoDeletion(constObjectAddress*object);
@@ -164,7 +166,8 @@ performDeletion(const ObjectAddress *object,
164166

165167
findAutoDeletableObjects(object,&oktodelete,depRel);
166168

167-
if (!recursiveDeletion(object,behavior,NULL,&oktodelete,depRel))
169+
if (!recursiveDeletion(object,behavior,NOTICE,
170+
NULL,&oktodelete,depRel))
168171
elog(ERROR,"Cannot drop %s because other objects depend on it"
169172
"\n\tUse DROP ... CASCADE to drop the dependent objects too",
170173
objDescription);
@@ -183,10 +186,12 @@ performDeletion(const ObjectAddress *object,
183186
* CASCADE.
184187
*
185188
* This is currently used only to clean out the contents of a schema
186-
* (namespace): the passed object is a namespace.
189+
* (namespace): the passed object is a namespace. We normally want this
190+
* to be done silently, so there's an option to suppress NOTICE messages.
187191
*/
188192
void
189-
deleteWhatDependsOn(constObjectAddress*object)
193+
deleteWhatDependsOn(constObjectAddress*object,
194+
boolshowNotices)
190195
{
191196
char*objDescription;
192197
RelationdepRel;
@@ -218,7 +223,9 @@ deleteWhatDependsOn(const ObjectAddress *object)
218223
* stuff dependent on the given object.
219224
*/
220225
if (!deleteDependentObjects(object,objDescription,
221-
DROP_CASCADE,&oktodelete,depRel))
226+
DROP_CASCADE,
227+
showNotices ?NOTICE :DEBUG1,
228+
&oktodelete,depRel))
222229
elog(ERROR,"Failed to drop all objects depending on %s",
223230
objDescription);
224231

@@ -342,7 +349,7 @@ findAutoDeletableObjects(const ObjectAddress *object,
342349
* depRel is the already-open pg_depend relation.
343350
*
344351
*
345-
* In RESTRICT mode, we perform all the deletions anyway, but elog aNOTICE
352+
* In RESTRICT mode, we perform all the deletions anyway, but elog amessage
346353
* and return FALSE if we find a restriction violation. performDeletion
347354
* will then abort the transaction to nullify the deletions. We have to
348355
* do it this way to (a) report all the direct and indirect dependencies
@@ -370,6 +377,7 @@ findAutoDeletableObjects(const ObjectAddress *object,
370377
staticbool
371378
recursiveDeletion(constObjectAddress*object,
372379
DropBehaviorbehavior,
380+
intmsglevel,
373381
constObjectAddress*callingObject,
374382
ObjectAddresses*oktodelete,
375383
RelationdepRel)
@@ -518,18 +526,17 @@ recursiveDeletion(const ObjectAddress *object,
518526
getObjectDescription(&owningObject));
519527
elseif (behavior==DROP_RESTRICT)
520528
{
521-
elog(NOTICE,"%s depends on %s",
529+
elog(msglevel,"%s depends on %s",
522530
getObjectDescription(&owningObject),
523531
objDescription);
524532
ok= false;
525533
}
526534
else
527-
elog(NOTICE,"Drop cascades to %s",
535+
elog(msglevel,"Drop cascades to %s",
528536
getObjectDescription(&owningObject));
529537

530-
if (!recursiveDeletion(&owningObject,behavior,
531-
object,
532-
oktodelete,depRel))
538+
if (!recursiveDeletion(&owningObject,behavior,msglevel,
539+
object,oktodelete,depRel))
533540
ok= false;
534541

535542
pfree(objDescription);
@@ -546,7 +553,8 @@ recursiveDeletion(const ObjectAddress *object,
546553
* constraint.
547554
*/
548555
if (!deleteDependentObjects(object,objDescription,
549-
behavior,oktodelete,depRel))
556+
behavior,msglevel,
557+
oktodelete,depRel))
550558
ok= false;
551559

552560
/*
@@ -613,6 +621,7 @@ static bool
613621
deleteDependentObjects(constObjectAddress*object,
614622
constchar*objDescription,
615623
DropBehaviorbehavior,
624+
intmsglevel,
616625
ObjectAddresses*oktodelete,
617626
RelationdepRel)
618627
{
@@ -664,18 +673,17 @@ deleteDependentObjects(const ObjectAddress *object,
664673
getObjectDescription(&otherObject));
665674
elseif (behavior==DROP_RESTRICT)
666675
{
667-
elog(NOTICE,"%s depends on %s",
676+
elog(msglevel,"%s depends on %s",
668677
getObjectDescription(&otherObject),
669678
objDescription);
670679
ok= false;
671680
}
672681
else
673-
elog(NOTICE,"Drop cascades to %s",
682+
elog(msglevel,"Drop cascades to %s",
674683
getObjectDescription(&otherObject));
675684

676-
if (!recursiveDeletion(&otherObject,behavior,
677-
object,
678-
oktodelete,depRel))
685+
if (!recursiveDeletion(&otherObject,behavior,msglevel,
686+
object,oktodelete,depRel))
679687
ok= false;
680688
break;
681689
caseDEPENDENCY_AUTO:
@@ -689,9 +697,8 @@ deleteDependentObjects(const ObjectAddress *object,
689697
elog(DEBUG1,"Drop auto-cascades to %s",
690698
getObjectDescription(&otherObject));
691699

692-
if (!recursiveDeletion(&otherObject,behavior,
693-
object,
694-
oktodelete,depRel))
700+
if (!recursiveDeletion(&otherObject,behavior,msglevel,
701+
object,oktodelete,depRel))
695702
ok= false;
696703
break;
697704
caseDEPENDENCY_PIN:

‎src/backend/catalog/namespace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.47 2003/02/09 06:56:26 tgl Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.48 2003/03/06 22:54:49 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -1698,7 +1698,7 @@ RemoveTempRelations(Oid tempNamespaceId)
16981698
object.objectId=tempNamespaceId;
16991699
object.objectSubId=0;
17001700

1701-
deleteWhatDependsOn(&object);
1701+
deleteWhatDependsOn(&object, false);
17021702
}
17031703

17041704
/*

‎src/include/catalog/dependency.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: dependency.h,v 1.6 2003/02/07 01:33:06 tgl Exp $
10+
* $Id: dependency.h,v 1.7 2003/03/06 22:54:49 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -84,7 +84,8 @@ typedef struct ObjectAddress
8484
externvoidperformDeletion(constObjectAddress*object,
8585
DropBehaviorbehavior);
8686

87-
externvoiddeleteWhatDependsOn(constObjectAddress*object);
87+
externvoiddeleteWhatDependsOn(constObjectAddress*object,
88+
boolshowNotices);
8889

8990
externvoidrecordDependencyOnExpr(constObjectAddress*depender,
9091
Node*expr,List*rtable,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp