8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -97,12 +97,14 @@ static void findAutoDeletableObjects(const ObjectAddress *object,
97
97
Relation depRel );
98
98
static bool recursiveDeletion (const ObjectAddress * object ,
99
99
DropBehavior behavior ,
100
+ int msglevel ,
100
101
const ObjectAddress * callingObject ,
101
102
ObjectAddresses * oktodelete ,
102
103
Relation depRel );
103
104
static bool deleteDependentObjects (const ObjectAddress * object ,
104
105
const char * objDescription ,
105
106
DropBehavior behavior ,
107
+ int msglevel ,
106
108
ObjectAddresses * oktodelete ,
107
109
Relation depRel );
108
110
static void doDeletion (const ObjectAddress * object );
@@ -164,7 +166,8 @@ performDeletion(const ObjectAddress *object,
164
166
165
167
findAutoDeletableObjects (object , & oktodelete , depRel );
166
168
167
- if (!recursiveDeletion (object , behavior , NULL , & oktodelete , depRel ))
169
+ if (!recursiveDeletion (object , behavior , NOTICE ,
170
+ NULL , & oktodelete , depRel ))
168
171
elog (ERROR , "Cannot drop %s because other objects depend on it"
169
172
"\n\tUse DROP ... CASCADE to drop the dependent objects too" ,
170
173
objDescription );
@@ -183,10 +186,12 @@ performDeletion(const ObjectAddress *object,
183
186
* CASCADE.
184
187
*
185
188
* 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.
187
191
*/
188
192
void
189
- deleteWhatDependsOn (const ObjectAddress * object )
193
+ deleteWhatDependsOn (const ObjectAddress * object ,
194
+ bool showNotices )
190
195
{
191
196
char * objDescription ;
192
197
Relation depRel ;
@@ -218,7 +223,9 @@ deleteWhatDependsOn(const ObjectAddress *object)
218
223
* stuff dependent on the given object.
219
224
*/
220
225
if (!deleteDependentObjects (object , objDescription ,
221
- DROP_CASCADE , & oktodelete , depRel ))
226
+ DROP_CASCADE ,
227
+ showNotices ? NOTICE : DEBUG1 ,
228
+ & oktodelete , depRel ))
222
229
elog (ERROR , "Failed to drop all objects depending on %s" ,
223
230
objDescription );
224
231
@@ -342,7 +349,7 @@ findAutoDeletableObjects(const ObjectAddress *object,
342
349
* depRel is the already-open pg_depend relation.
343
350
*
344
351
*
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
346
353
* and return FALSE if we find a restriction violation. performDeletion
347
354
* will then abort the transaction to nullify the deletions. We have to
348
355
* do it this way to (a) report all the direct and indirect dependencies
@@ -370,6 +377,7 @@ findAutoDeletableObjects(const ObjectAddress *object,
370
377
static bool
371
378
recursiveDeletion (const ObjectAddress * object ,
372
379
DropBehavior behavior ,
380
+ int msglevel ,
373
381
const ObjectAddress * callingObject ,
374
382
ObjectAddresses * oktodelete ,
375
383
Relation depRel )
@@ -518,18 +526,17 @@ recursiveDeletion(const ObjectAddress *object,
518
526
getObjectDescription (& owningObject ));
519
527
else if (behavior == DROP_RESTRICT )
520
528
{
521
- elog (NOTICE , "%s depends on %s" ,
529
+ elog (msglevel , "%s depends on %s" ,
522
530
getObjectDescription (& owningObject ),
523
531
objDescription );
524
532
ok = false;
525
533
}
526
534
else
527
- elog (NOTICE , "Drop cascades to %s" ,
535
+ elog (msglevel , "Drop cascades to %s" ,
528
536
getObjectDescription (& owningObject ));
529
537
530
- if (!recursiveDeletion (& owningObject , behavior ,
531
- object ,
532
- oktodelete , depRel ))
538
+ if (!recursiveDeletion (& owningObject , behavior , msglevel ,
539
+ object , oktodelete , depRel ))
533
540
ok = false;
534
541
535
542
pfree (objDescription );
@@ -546,7 +553,8 @@ recursiveDeletion(const ObjectAddress *object,
546
553
* constraint.
547
554
*/
548
555
if (!deleteDependentObjects (object , objDescription ,
549
- behavior , oktodelete , depRel ))
556
+ behavior , msglevel ,
557
+ oktodelete , depRel ))
550
558
ok = false;
551
559
552
560
/*
@@ -613,6 +621,7 @@ static bool
613
621
deleteDependentObjects (const ObjectAddress * object ,
614
622
const char * objDescription ,
615
623
DropBehavior behavior ,
624
+ int msglevel ,
616
625
ObjectAddresses * oktodelete ,
617
626
Relation depRel )
618
627
{
@@ -664,18 +673,17 @@ deleteDependentObjects(const ObjectAddress *object,
664
673
getObjectDescription (& otherObject ));
665
674
else if (behavior == DROP_RESTRICT )
666
675
{
667
- elog (NOTICE , "%s depends on %s" ,
676
+ elog (msglevel , "%s depends on %s" ,
668
677
getObjectDescription (& otherObject ),
669
678
objDescription );
670
679
ok = false;
671
680
}
672
681
else
673
- elog (NOTICE , "Drop cascades to %s" ,
682
+ elog (msglevel , "Drop cascades to %s" ,
674
683
getObjectDescription (& otherObject ));
675
684
676
- if (!recursiveDeletion (& otherObject , behavior ,
677
- object ,
678
- oktodelete , depRel ))
685
+ if (!recursiveDeletion (& otherObject , behavior , msglevel ,
686
+ object , oktodelete , depRel ))
679
687
ok = false;
680
688
break ;
681
689
case DEPENDENCY_AUTO :
@@ -689,9 +697,8 @@ deleteDependentObjects(const ObjectAddress *object,
689
697
elog (DEBUG1 , "Drop auto-cascades to %s" ,
690
698
getObjectDescription (& otherObject ));
691
699
692
- if (!recursiveDeletion (& otherObject , behavior ,
693
- object ,
694
- oktodelete , depRel ))
700
+ if (!recursiveDeletion (& otherObject , behavior , msglevel ,
701
+ object , oktodelete , depRel ))
695
702
ok = false;
696
703
break ;
697
704
case DEPENDENCY_PIN :
0 commit comments