Re: Add support for DEFAULT specification in COPY FROM

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: Israel Barth Rubio <barthisrael(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add support for DEFAULT specification in COPY FROM
Date: 2022-10-07 19:16:22
Message-ID: CALNJ-vT09rVCOZ0fKt68+B6pSckuFqa5uC2nKxt=yNJj3=OCPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 7, 2022 at 12:09 PM Israel Barth Rubio <barthisrael(at)gmail(dot)com>
wrote:

> Hello Zhihong,
>
> > + /* attribute is NOT to be copied from input */
> >
> > I think saying `is NOT copied from input` should suffice.
> >
> > + /* fieldno is 0-index and attnum is 1-index */
> >
> > 0-index -> 0-indexed
>
> I have applied both suggestions, thanks! I'll submit a 4th version
> of the patch soon.
>
> > + defaults = (bool *) palloc0(num_phys_attrs * sizeof(bool));
> > + MemSet(defaults, false, num_phys_attrs * sizeof(bool));
> >
> > Is the MemSet() call necessary ?
>
> I would say it is, so it initializes the array with all flags set to false.
> Later, if it detects attributes that should evaluate their default
> expression,
> it would set the flag to true.
>
> Am I missing something?
>
> Regards,
> Israel.
>
Hi,
For the last question, please take a look at:

#define MemSetAligned(start, val, len) \

which is called by palloc0().

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Israel Barth Rubio 2022-10-07 19:17:35 Re: Add support for DEFAULT specification in COPY FROM
Previous Message Andres Freund 2022-10-07 19:16:08 Re: meson PGXS compatibility