[NOVICE] Why is there a doubtful copyObject call in add_vars_to_targetlist - Mailing list pgsql-novice

From Neha Khatri
Subject [NOVICE] Why is there a doubtful copyObject call in add_vars_to_targetlist
Date
Msg-id CAFO0U+9oT7fBG8oUWN3B_sd0i_rfvoQ45LhSmeUQzhRQf_Y3-g@mail.gmail.com
Whole thread Raw
List pgsql-novice
Hi,

I was debugging that when does the function _copyVar get invoked, and the first hit for that was in the add_vars_to_targetlist. There I happened to see the following comment:

/* XXX is copyObject necessary here? */

Further digging showed that this copyObject got added in the commit 5efe3121: 

+       /* XXX is copyObject necessary here? */
+ rel->targetlist = lappend(rel->targetlist,
+                           create_tl_element((Var *) copyObject(var),
+                                             length(rel->targetlist) + 1));

This copyObject still exits in the current code. So I was wondering if the comment question still holds good and why the question there in first place.
To make a new Var object, copyObject seem to be the right choice, then why the doubt?

Regards,
Neha

pgsql-novice by date:

Previous
From: Yaser Raja
Date:
Subject: Re: [NOVICE] Adding a third DR PostgreSQL native replication
Next
From: Herman Bergwerf
Date:
Subject: [NOVICE] Extend GIN