Re: Add --include-table-data-where option to pg_dump, to export only a subset of table data

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Carter Thaxton <carter(dot)thaxton(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add --include-table-data-where option to pg_dump, to export only a subset of table data
Date: 2018-05-21 23:00:52
Message-ID: CAEepm=28jGiCv0x+EmQkuXK-NC_sFSr35skqw7a4BAOfV3HOTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 22, 2018 at 4:05 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> * Carter Thaxton (carter(dot)thaxton(at)gmail(dot)com) wrote:
>> pg_dump --include-table-data-where=largetable:"created_at >=
>> '2018-05-01'" database_name
>
> I've wanted something similar to this in the past as well, and, as
> you've seen, we have some support for this kind of thing in pg_dump
> already and what you're doing is exposing that.

+1

>> I've prepared a proposed patch for this, which is attached. The code
>> changes are rather straightforward. I did have to add the ability to carry
>> around an extra pointer-sized object to the simple_list implementation, in
>> order to allow the filter clause to be associated to the matching oids of
>> the table pattern. It seemed the best way to augment the existing
>> simple_list implementation, but change as little as possible elsewhere in
>> the codebase. (Note that SimpleOidList is actually only used by pg_dump).
>>
>> Feel free to review and propose any amendments.
>
> I've only taken a quick look but I don't see any regression tests, for
> starters, and it's not clear if this can be passed multiple times for
> one pg_dump run (I'd certainly hope that it could be...).
>
> Also, if you haven't already, this should be registered on the
> commitfest app, so we don't lose track of it.

Thanks for doing that. Unfortunately the patch seems to be corrupted
in some way, maybe ANSI control characters or something... perhaps you
set colour.ui = always in your git config, instead of auto? You might
also consider using git format-patch so you can include a brief commit
message that explains the feature.

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2018-05-22 00:07:17 Re: [HACKERS] kqueue
Previous Message Carter Thaxton 2018-05-21 21:48:09 Re: Add --include-table-data-where option to pg_dump, to export only a subset of table data