Avoid possible useless call to makeNode function (src/backend/commands/view.c)

Started by Ranier Vilelaabout 1 year ago3 messages
#1Ranier Vilela
ranier.vf@gmail.com
1 attachment(s)

Hi.

With the function *DefineVirtualRelation* has a possible
useless call to *makeNode* function, which invokes palloc.

So, reduce the scope for the variable to inner else
where it is really necessary.

trivial patch attached.

best regards,
Ranier Vilela

Attachments:

0001-avoid-possible-useless-palloc-view.patchapplication/octet-stream; name=0001-avoid-possible-useless-palloc-view.patchDownload
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index fdad833832..2bd49eb55e 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -47,7 +47,6 @@ DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace,
 {
 	Oid			viewOid;
 	LOCKMODE	lockmode;
-	CreateStmt *createStmt = makeNode(CreateStmt);
 	List	   *attrList;
 	ListCell   *t;
 
@@ -223,6 +222,7 @@ DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace,
 	}
 	else
 	{
+		CreateStmt *createStmt = makeNode(CreateStmt);
 		ObjectAddress address;
 
 		/*
#2David Rowley
dgrowleyml@gmail.com
In reply to: Ranier Vilela (#1)
Re: Avoid possible useless call to makeNode function (src/backend/commands/view.c)

On Wed, 30 Oct 2024 at 01:07, Ranier Vilela <ranier.vf@gmail.com> wrote:

With the function *DefineVirtualRelation* has a possible
useless call to *makeNode* function, which invokes palloc.

So, reduce the scope for the variable to inner else
where it is really necessary.

Seem legit. I can take care of that.

David

#3Ranier Vilela
ranier.vf@gmail.com
In reply to: David Rowley (#2)
Re: Avoid possible useless call to makeNode function (src/backend/commands/view.c)

Em ter., 29 de out. de 2024 às 09:25, David Rowley <dgrowleyml@gmail.com>
escreveu:

On Wed, 30 Oct 2024 at 01:07, Ranier Vilela <ranier.vf@gmail.com> wrote:

With the function *DefineVirtualRelation* has a possible
useless call to *makeNode* function, which invokes palloc.

So, reduce the scope for the variable to inner else
where it is really necessary.

Seem legit. I can take care of that.

Thanks David, for the commit.

best regards,
Ranier Vilela