RE: ON CONFLICT DO NOTHING on pg_dump - Mailing list pgsql-hackers

From Ideriha, Takeshi
Subject RE: ON CONFLICT DO NOTHING on pg_dump
Date
Msg-id 4E72940DA2BF16479384A86D54D0988A567B0273@G01JPEXMBKW04
Whole thread Raw
In response to ON CONFLICT DO NOTHING on pg_dump  (Surafel Temesgen <surafel3000@gmail.com>)
Responses Re: ON CONFLICT DO NOTHING on pg_dump
Re: ON CONFLICT DO NOTHING on pg_dump
List pgsql-hackers
>From: Surafel Temesgen [mailto:surafel3000@gmail.com] 
>Subject: ON CONFLICT DO NOTHING on pg_dump

>Sometimes I have to maintain two similar database and I have to update one from the other and notice having the option
toadd ON CONFLICT DO NOTHING clause to >INSERT command in the dump data will allows pg_restore to be done with free of
ignoreerror.
 

Hi,
I feel like that on-conflict-do-nothing support is useful especially coupled with --data-only option.
Only the difference of data can be restored.

>The attache patch add --on-conflect-do-nothing option to pg_dump in order to do the above. 

The followings are some comments.

+      <term><option>--on-conflect-do-nothing</option></term>
Here's a typo: conflect -> conflict. This typo also applies to pg_dump.c

        printf(_("  --inserts                    dump data as INSERT commands, rather than COPY\n"));
+       printf(_("  --on-conflect-do-nothing     dump data as INSERT commands with on conflect do nothing\n"));
        printf(_("  --no-comments                do not dump comments\n"));

The output of help should be in alphabetical order according to the convention. So changing the order seems logical. 
Please apply my review to the documentation as well.
By the way, 4d6a854 breaks the patch on this point.

+        This option is not valid unless <option>--inserts</option> is also specified.
+       </para>
       
+       if (dopt.do_nothing && !dopt.dump_inserts)
+               exit_horribly(NULL, "option --on-conflect-do-nothing requires option --inserts\n");

How about mentioning --column-inserts? --on-conflict-do-nothing with --column-inserts should work.

Do you have any plan to support on-conlict-do-update? Supporting this seems to me complicated and take much time so I
don'tmind not implementing this.
 

What do you think about adding some test cases? 
command_fails_like() at 001_basic.pl checks command fail pattern with invalid comnibation of option.
And 002_pg_dump.pl checks the feature iteself.

Regards,
Takeshi Ideriha

pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: Proposal: Partitioning Advisor for PostgreSQL
Next
From: Dilip Kumar
Date:
Subject: Re: Proposal: Partitioning Advisor for PostgreSQL