Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f7cffbb

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 be cluttered with 'Drop cascades to table foo' every time someone uses a temp table...
1 parent 0c693b4 commit f7cffbb

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

src/backend/catalog/dependency.c

+27-20
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
Relation depRel);
9898
static bool recursiveDeletion(const ObjectAddress *object,
9999
DropBehavior behavior,
100+
int msglevel,
100101
const ObjectAddress *callingObject,
101102
ObjectAddresses *oktodelete,
102103
Relation depRel);
103104
static bool deleteDependentObjects(const ObjectAddress *object,
104105
const char *objDescription,
105106
DropBehavior behavior,
107+
int msglevel,
106108
ObjectAddresses *oktodelete,
107109
Relation depRel);
108110
static void doDeletion(const ObjectAddress *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(const ObjectAddress *object)
193+
deleteWhatDependsOn(const ObjectAddress *object,
194+
bool showNotices)
190195
{
191196
char *objDescription;
192197
Relation depRel;
@@ -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 a NOTICE
352+
* In RESTRICT mode, we perform all the deletions anyway, but elog a message
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
static bool
371378
recursiveDeletion(const ObjectAddress *object,
372379
DropBehavior behavior,
380+
int msglevel,
373381
const ObjectAddress *callingObject,
374382
ObjectAddresses *oktodelete,
375383
Relation depRel)
@@ -518,18 +526,17 @@ recursiveDeletion(const ObjectAddress *object,
518526
getObjectDescription(&owningObject));
519527
else if (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(const ObjectAddress *object,
614622
const char *objDescription,
615623
DropBehavior behavior,
624+
int msglevel,
616625
ObjectAddresses *oktodelete,
617626
Relation depRel)
618627
{
@@ -664,18 +673,17 @@ deleteDependentObjects(const ObjectAddress *object,
664673
getObjectDescription(&otherObject));
665674
else if (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
case DEPENDENCY_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
case DEPENDENCY_PIN:

src/backend/catalog/namespace.c

+2-2
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

+3-2
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
extern void performDeletion(const ObjectAddress *object,
8585
DropBehavior behavior);
8686

87-
extern void deleteWhatDependsOn(const ObjectAddress *object);
87+
extern void deleteWhatDependsOn(const ObjectAddress *object,
88+
bool showNotices);
8889

8990
extern void recordDependencyOnExpr(const ObjectAddress *depender,
9091
Node *expr, List *rtable,

0 commit comments

Comments
 (0)