Use <unnamed> for name of unnamed portal's memory context

Started by Peter Eisentrautover 5 years ago5 messages
#1Peter Eisentraut
peter.eisentraut@2ndquadrant.com
1 attachment(s)

I propose the attached little patch to set the name of the memory
context of an unnamed portal to "<unnamed>" instead of just an empty
string. Otherwise the debug memory context dump looks a little
confusing. We use this convention elsewhere for making unnamed
statements etc. more clearly visible.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

0001-Use-unnamed-for-name-of-unnamed-portal-s-memory-cont.patchtext/plain; charset=UTF-8; name=0001-Use-unnamed-for-name-of-unnamed-portal-s-memory-cont.patch; x-mac-creator=0; x-mac-type=0Download
From 409abc15293efdc8ec65db77efa40d2d9517ad0b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Sat, 5 Sep 2020 08:09:51 +0200
Subject: [PATCH] Use <unnamed> for name of unnamed portal's memory context

Otherwise just printing an empty string makes the memory context debug
output slightly confusing.
---
 src/backend/utils/mmgr/portalmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c
index 7072ce48a3..bee81368aa 100644
--- a/src/backend/utils/mmgr/portalmem.c
+++ b/src/backend/utils/mmgr/portalmem.c
@@ -221,7 +221,7 @@ CreatePortal(const char *name, bool allowDup, bool dupSilent)
 	PortalHashTableInsert(portal, name);
 
 	/* reuse portal->name copy */
-	MemoryContextSetIdentifier(portal->portalContext, portal->name);
+	MemoryContextSetIdentifier(portal->portalContext, portal->name[0] ? portal->name : "<unnamed>");
 
 	return portal;
 }
-- 
2.28.0

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Peter Eisentraut (#1)
Re: Use <unnamed> for name of unnamed portal's memory context

so 5. 9. 2020 v 8:14 odesílatel Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> napsal:

I propose the attached little patch to set the name of the memory
context of an unnamed portal to "<unnamed>" instead of just an empty
string. Otherwise the debug memory context dump looks a little
confusing. We use this convention elsewhere for making unnamed
statements etc. more clearly visible.

+1

Pavel

Show quoted text

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#3Julien Rouhaud
rjuju123@gmail.com
In reply to: Pavel Stehule (#2)
Re: Use <unnamed> for name of unnamed portal's memory context

On Sat, Sep 5, 2020 at 8:25 AM Pavel Stehule <pavel.stehule@gmail.com> wrote:

so 5. 9. 2020 v 8:14 odesílatel Peter Eisentraut <peter.eisentraut@2ndquadrant.com> napsal:

I propose the attached little patch to set the name of the memory
context of an unnamed portal to "<unnamed>" instead of just an empty
string. Otherwise the debug memory context dump looks a little
confusing. We use this convention elsewhere for making unnamed
statements etc. more clearly visible.

+1

+1 too, and obviously patch looks good.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Julien Rouhaud (#3)
Re: Use <unnamed> for name of unnamed portal's memory context

Julien Rouhaud <rjuju123@gmail.com> writes:

+1 too, and obviously patch looks good.

The adjacent comment needs updating.

regards, tom lane

#5Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: Tom Lane (#4)
Re: Use <unnamed> for name of unnamed portal's memory context

On 2020-09-05 17:10, Tom Lane wrote:

Julien Rouhaud <rjuju123@gmail.com> writes:

+1 too, and obviously patch looks good.

The adjacent comment needs updating.

committed with that change

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services