Re: Assert failure due to "drop schema pg_temp_3 cascade" for temporary tables and \d+ is not showing any info after drooping temp table schema

Michael Paquier <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.general
Message-ID <[email protected]>
On Tue, Jan 07, 2020 at 07:55:17PM -0500, Tom Lane wrote:
> * Please revert a052f6c as a separate commit specifically doing that,
> so that when it comes time to make the release notes, it's clear that
> a052f6c doesn't require documentation.

Okay.  Committed the revert first then.

> * I think the check on log_min_messages <= LOG is probably wrong, since
> LOG sorts out of order for this purpose.  Compare is_log_level_output()
> in elog.c.  I'd suggest not bothering with trying to optimize away the
> get_namespace_name call here; we shouldn't be in this code path often
> enough for performance to matter, and nobody ever cared about it before.

Done.

> * I don't greatly like the notation
>     dropping orphan temp table \"%s.(null).%s\" ...
> and I bet Robert won't either.  Not sure offhand about a better
> idea --- maybe
>     dropping orphan temp table \"%s\" with OID %u in database \"%s\"

And done this way as per the attached.  I am of course open to
objections or better ideas, though this looks formulation looks pretty
good to me.  Robert?
--
Michael
drop-temp-schema-adjust-v3.patch (text/x-diff, 1.2 KB)
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index f0e40e36af..22f7bdeaff 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -2202,6 +2202,7 @@ do_autovacuum(void)
 		Oid			relid = lfirst_oid(cell);
 		Form_pg_class classForm;
 		ObjectAddress object;
+		char	   *nspname;
 
 		/*
 		 * Check for user-requested abort.
@@ -2249,12 +2250,18 @@ do_autovacuum(void)
 			continue;
 		}
 
-		/* OK, let's delete it */
-		ereport(LOG,
-				(errmsg("autovacuum: dropping orphan temp table \"%s.%s.%s\"",
-						get_database_name(MyDatabaseId),
-						get_namespace_name(classForm->relnamespace),
-						NameStr(classForm->relname))));
+		nspname = get_namespace_name(classForm->relnamespace);
+
+		if (nspname != NULL)
+			ereport(LOG,
+					(errmsg("autovacuum: dropping orphan temp table \"%s.%s.%s\"",
+							get_database_name(MyDatabaseId),
+							nspname, NameStr(classForm->relname))));
+		else
+			ereport(LOG,
+					(errmsg("autovacuum: dropping orphan temp table \"%s\" with OID %u in database \"%s\"",
+							NameStr(classForm->relname), relid,
+							get_database_name(MyDatabaseId))));
 
 		object.classId = RelationRelationId;
 		object.objectId = relid;
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl4VNrEACgkQnvQgOdby
QH2nJQ//ahvuMbCY6n+90gBkqesQBX1qt6MmnMdmObcGuHTo4yDvK75byOgrfFXs
/Tw1RwLIjFgQ0xXfjIleRqzbhNtvYhww/tWAxF6B0J4isj2OT2oFFiNn8m1y9wyR
npCTHvVbgA3l+2lU3J+8suwuyiMTaqBaD4b6nVzywZobHKO2+UhVj/ZYncMKiULo
ms8gaEcmbb9dr3DrpO3fNJmVeeh3zXQz8460BW2uhouqIuwy/6wINH9GaxmUNoUY
BndJLvKkrZFRT0m+A8rq7/GafW3d0qGhBRUZmQRZIbYaCfPkAYkXwTx+mGL8Zx0x
pCvUm6Vlu0BV9tD70qSLOtGq5jOaZLexbHAmBKg8LnVDZqa0sAFD+0YemRfs6Jm4
ozIGkrCHxNlZC+9Olc3FDeba4CT6kfs45rQ+kX6GGS9XGHorB0GEn6a7fgCM26Ie
1UMycGxY6j+DgJ9dJbZIfspo8WhHIWfsUkrzyBvRI996Y6bn0l8brRUvZ47ogXSX
5HXvekIHsDZm9/ygg0W3t+9bcaCQCczMMTkbBuDItctTsHd831vwekVkf2Mjzg+l
+wvKNrXPeSW2KF5kaOsJ6ZeT/fSJe3C+cEyRPXffOimyRZCmOvMOne2aZNeGRi60
37urhvpmzSk2cciRTl5t+gSSPG9PePAv3VzYjYxCiaIq5z8i9SM=
=Vumy
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.