Why is there a doubtful copyObject call in add_vars_to_targetlist

From: Neha Khatri <nehakhatri5(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Why is there a doubtful copyObject call in add_vars_to_targetlist
Date: 2017-03-13 01:22:06
Message-ID: CAFO0U+9oT7fBG8oUWN3B_sd0i_rfvoQ45LhSmeUQzhRQf_Y3-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2017-03-13 01:32:47 Re: PATCH: Batch/pipelining support for libpq
Previous Message David Rowley 2017-03-13 01:19:05 Re: BRIN cost estimate

Browse pgsql-novice by date

  From Date Subject
Next Message David Rowley 2017-03-13 01:50:53 Re: [NOVICE] Why is there a doubtful copyObject call in add_vars_to_targetlist
Previous Message Yaser Raja 2017-03-12 15:53:53 Re: Adding a third DR PostgreSQL native replication