8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.24 2008/03/24 19:12:49 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.25 2008/03/24 19:47:35 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -454,11 +454,14 @@ typedef struct
454
454
* checkSharedDependencies
455
455
*
456
456
* Check whether there are shared dependency entries for a given shared
457
- * object. Returns a string containing a newline-separated list of object
457
+ * object; return true if so.
458
+ *
459
+ * In addition, return a string containing a newline-separated list of object
458
460
* descriptions that depend on the shared object, or NULL if none is found.
459
- * The size of the returned string is limited to about MAX_REPORTED_DEPS lines;
460
- * if there are more objects than that, the output is returned truncated at
461
- * that point while the full message is logged to the postmaster log.
461
+ * We actually return two such strings; the "detail" result is suitable for
462
+ * returning to the client as an errdetail() string, and is limited in size.
463
+ * The "detail_log" string is potentially much longer, and should be emitted
464
+ * to the server log only.
462
465
*
463
466
* We can find three different kinds of dependencies: dependencies on objects
464
467
* of the current database; dependencies on shared objects; and dependencies
@@ -468,8 +471,9 @@ typedef struct
468
471
*
469
472
* If we find a SHARED_DEPENDENCY_PIN entry, we can error out early.
470
473
*/
471
- char *
472
- checkSharedDependencies (Oid classId , Oid objectId )
474
+ bool
475
+ checkSharedDependencies (Oid classId , Oid objectId ,
476
+ char * * detail_msg , char * * detail_log_msg )
473
477
{
474
478
Relation sdepRel ;
475
479
ScanKeyData key [2 ];
@@ -487,9 +491,7 @@ checkSharedDependencies(Oid classId, Oid objectId)
487
491
/*
488
492
* We limit the number of dependencies reported to the client to
489
493
* MAX_REPORTED_DEPS, since client software may not deal well with
490
- * enormous error strings. The server log always gets a full report,
491
- * which is collected in a separate StringInfo if and only if we detect
492
- * that the client report is going to be truncated.
494
+ * enormous error strings. The server log always gets a full report.
493
495
*/
494
496
#define MAX_REPORTED_DEPS 100
495
497
@@ -546,15 +548,9 @@ checkSharedDependencies(Oid classId, Oid objectId)
546
548
sdepForm -> deptype , 0 );
547
549
}
548
550
else
549
- {
550
551
numNotReportedDeps ++ ;
551
- /* initialize the server-only log line */
552
- if (alldescs .len == 0 )
553
- appendBinaryStringInfo (& alldescs , descs .data , descs .len );
554
-
555
- storeObjectDescription (& alldescs , LOCAL_OBJECT , & object ,
556
- sdepForm -> deptype , 0 );
557
- }
552
+ storeObjectDescription (& alldescs , LOCAL_OBJECT , & object ,
553
+ sdepForm -> deptype , 0 );
558
554
}
559
555
else if (sdepForm -> dbid == InvalidOid )
560
556
{
@@ -565,15 +561,9 @@ checkSharedDependencies(Oid classId, Oid objectId)
565
561
sdepForm -> deptype , 0 );
566
562
}
567
563
else
568
- {
569
564
numNotReportedDeps ++ ;
570
- /* initialize the server-only log line */
571
- if (alldescs .len == 0 )
572
- appendBinaryStringInfo (& alldescs , descs .data , descs .len );
573
-
574
- storeObjectDescription (& alldescs , SHARED_OBJECT , & object ,
575
- sdepForm -> deptype , 0 );
576
- }
565
+ storeObjectDescription (& alldescs , SHARED_OBJECT , & object ,
566
+ sdepForm -> deptype , 0 );
577
567
}
578
568
else
579
569
{
@@ -612,9 +602,7 @@ checkSharedDependencies(Oid classId, Oid objectId)
612
602
heap_close (sdepRel , AccessShareLock );
613
603
614
604
/*
615
- * Report dependencies on remote databases. If we're truncating the
616
- * output already, don't put a line per database, but a single one for all
617
- * of them. Otherwise add as many as fit in MAX_REPORTED_DEPS.
605
+ * Summarize dependencies in remote databases.
618
606
*/
619
607
foreach (cell , remDeps )
620
608
{
@@ -631,15 +619,9 @@ checkSharedDependencies(Oid classId, Oid objectId)
631
619
SHARED_DEPENDENCY_INVALID , dep -> count );
632
620
}
633
621
else
634
- {
635
622
numNotReportedDbs ++ ;
636
- /* initialize the server-only log line */
637
- if (alldescs .len == 0 )
638
- appendBinaryStringInfo (& alldescs , descs .data , descs .len );
639
-
640
- storeObjectDescription (& alldescs , REMOTE_OBJECT , & object ,
641
- SHARED_DEPENDENCY_INVALID , dep -> count );
642
- }
623
+ storeObjectDescription (& alldescs , REMOTE_OBJECT , & object ,
624
+ SHARED_DEPENDENCY_INVALID , dep -> count );
643
625
}
644
626
645
627
list_free_deep (remDeps );
@@ -648,7 +630,8 @@ checkSharedDependencies(Oid classId, Oid objectId)
648
630
{
649
631
pfree (descs .data );
650
632
pfree (alldescs .data );
651
- return NULL ;
633
+ * detail_msg = * detail_log_msg = NULL ;
634
+ return false;
652
635
}
653
636
654
637
if (numNotReportedDeps > 0 )
@@ -660,22 +643,9 @@ checkSharedDependencies(Oid classId, Oid objectId)
660
643
"(see server log for list)" ),
661
644
numNotReportedDbs );
662
645
663
- if (numNotReportedDeps > 0 || numNotReportedDbs > 0 )
664
- {
665
- ObjectAddress obj ;
666
-
667
- obj .classId = classId ;
668
- obj .objectId = objectId ;
669
- obj .objectSubId = 0 ;
670
- ereport (LOG ,
671
- (errmsg ("there are objects dependent on %s" ,
672
- getObjectDescription (& obj )),
673
- errdetail ("%s" , alldescs .data )));
674
- }
675
-
676
- pfree (alldescs .data );
677
-
678
- return descs .data ;
646
+ * detail_msg = descs .data ;
647
+ * detail_log_msg = alldescs .data ;
648
+ return true;
679
649
}
680
650
681
651
/*
0 commit comments