88 *
99 *
1010 * 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 $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -454,11 +454,14 @@ typedef struct
454454 * checkSharedDependencies
455455 *
456456 * 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
458460 * 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.
462465 *
463466 * We can find three different kinds of dependencies: dependencies on objects
464467 * of the current database; dependencies on shared objects; and dependencies
@@ -468,8 +471,9 @@ typedef struct
468471 *
469472 * If we find a SHARED_DEPENDENCY_PIN entry, we can error out early.
470473 */
471- char *
472- checkSharedDependencies (Oid classId ,Oid objectId )
474+ bool
475+ checkSharedDependencies (Oid classId ,Oid objectId ,
476+ char * * detail_msg ,char * * detail_log_msg )
473477{
474478Relation sdepRel ;
475479ScanKeyData key [2 ];
@@ -487,9 +491,7 @@ checkSharedDependencies(Oid classId, Oid objectId)
487491/*
488492 * We limit the number of dependencies reported to the client to
489493 * 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.
493495 */
494496#define MAX_REPORTED_DEPS 100
495497
@@ -546,15 +548,9 @@ checkSharedDependencies(Oid classId, Oid objectId)
546548sdepForm -> deptype ,0 );
547549}
548550else
549- {
550551numNotReportedDeps ++ ;
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 );
558554}
559555else if (sdepForm -> dbid == InvalidOid )
560556{
@@ -565,15 +561,9 @@ checkSharedDependencies(Oid classId, Oid objectId)
565561sdepForm -> deptype ,0 );
566562}
567563else
568- {
569564numNotReportedDeps ++ ;
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 );
577567}
578568else
579569{
@@ -612,9 +602,7 @@ checkSharedDependencies(Oid classId, Oid objectId)
612602heap_close (sdepRel ,AccessShareLock );
613603
614604/*
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.
618606 */
619607foreach (cell ,remDeps )
620608{
@@ -631,15 +619,9 @@ checkSharedDependencies(Oid classId, Oid objectId)
631619SHARED_DEPENDENCY_INVALID ,dep -> count );
632620}
633621else
634- {
635622numNotReportedDbs ++ ;
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 );
643625}
644626
645627list_free_deep (remDeps );
@@ -648,7 +630,8 @@ checkSharedDependencies(Oid classId, Oid objectId)
648630{
649631pfree (descs .data );
650632pfree (alldescs .data );
651- return NULL ;
633+ * detail_msg = * detail_log_msg = NULL ;
634+ return false;
652635}
653636
654637if (numNotReportedDeps > 0 )
@@ -660,22 +643,9 @@ checkSharedDependencies(Oid classId, Oid objectId)
660643"(see server log for list)" ),
661644numNotReportedDbs );
662645
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;
679649}
680650
681651/*