Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQb2k-0005ED-74 for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 16:12:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQb2j-0001mS-3K for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 16:12:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQb2i-0001mI-OH for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 16:12:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQb2g-0008L6-DR for pgsql-general@postgresql.org; Wed, 06 Jun 2018 16:12:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w56GBvgF011090; Wed, 6 Jun 2018 12:11:57 -0400 From: Tom Lane To: Jerry Sievers cc: Adrian Klaver , pgsql-general@postgresql.org Subject: Re: Which backend using which pg_temp_N schema? In-reply-to: <877enbsyf3.fsf@jsievers.enova.com> References: <87o9go3nok.fsf@jsievers.enova.com> <81d847d2-59eb-0094-59cf-b91565213f44@aklaver.com> <87k1rc3ibz.fsf@jsievers.enova.com> <52ec7e75-9159-7879-fdeb-8d5d120b6ac9@aklaver.com> <877enbsyf3.fsf@jsievers.enova.com> Comments: In-reply-to Jerry Sievers message dated "Wed, 06 Jun 2018 10:54:40 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11088.1528301517.1@sss.pgh.pa.us> Date: Wed, 06 Jun 2018 12:11:57 -0400 Message-ID: <11089.1528301517@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jerry Sievers writes: > Yep thanks... but IMO something that simply exposes whatever internal > registry of temp schemas/PIDs (which I presume must exist) Not really. There are a couple of ways that one could identify a session's "BackendId", which is the "N" in the "pg_temp_N" name of the temp schema that it would use if it uses one. But I do not think there's any terribly reliable way to tell from outside the session whether it has actually done anything with the temp schema. If it hasn't, then at least in principle there could be objects in the schema that are left over from a crashed session that previously had the same BackendId. We only make an effort to clean out such objects at the time that a session first creates a temp object. In any case, I think you're right that this isn't exposed at the SQL level presently. regards, tom lane