Re: [feature]COPY FROM enable FORCE_NULL/FORCE_NOT_NULL on all columns

From: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>
To: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [feature]COPY FROM enable FORCE_NULL/FORCE_NOT_NULL on all columns
Date: 2022-12-27 11:02:15
Message-ID: CAGPVpCS=9S55SH4h0o25SS_fwJaCZ67ZW-d8NMOJa5N6oT4quQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Having FORCE_NULL(*) and FORCE_NOT_NULL(*) sounds good, since postgres
already has FORCE_QUOTE(*).

I just quickly tried out your patch. It worked for me as expected.

One little suggestion:

+ if (cstate->opts.force_notnull_all)
> + {
> + int i;
> + for(i = 0; i < num_phys_attrs; i++)
> + cstate->opts.force_notnull_flags[i] = true;
> + }

Instead of setting force_null/force_notnull flags for all columns, what
about simply setting "attnums" list to cstate->attnumlist?
Something like the following should be enough :

> if (cstate->opts.force_null_all)
> attnums = cstate->attnumlist;
> else
> attnums = CopyGetAttnums(tupDesc, cstate->rel, cstate->opts.force_null);

Thanks,
--
Melih Mutlu
Microsoft

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-12-27 11:37:20 Re: Perform streaming logical transactions by background workers and parallel apply
Previous Message Hayato Kuroda (Fujitsu) 2022-12-27 09:29:02 RE: Time delayed LR (WAS Re: logical replication restrictions)