Thread: pgsql: Add --section option to pg_dump and pg_restore.

pgsql: Add --section option to pg_dump and pg_restore.

From
Andrew Dunstan
Date:
Add --section option to pg_dump and pg_restore.

Valid values are --pre-data, data and post-data. The option can be
given more than once. --schema-only is equivalent to
--section=pre-data --section=post-data. --data-only is equivalent
to --section=data.

Andrew Dunstan, reviewed by Joachim Wieland and Josh Berkus.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a4cd6abcc901c1a8009c62a27f78696717bb8fe1

Modified Files
--------------
doc/src/sgml/ref/pg_dump.sgml        |   24 ++++++++++++++--
doc/src/sgml/ref/pg_restore.sgml     |   23 ++++++++++++++++
src/bin/pg_dump/common.c             |    2 +-
src/bin/pg_dump/dumputils.c          |   30 ++++++++++++++++++++
src/bin/pg_dump/dumputils.h          |    1 +
src/bin/pg_dump/pg_backup.h          |    9 ++++++
src/bin/pg_dump/pg_backup_archiver.c |   19 +++++++++++++
src/bin/pg_dump/pg_backup_archiver.h |    3 ++
src/bin/pg_dump/pg_dump.c            |   49 ++++++++++++++++++++++++++++++++-
src/bin/pg_dump/pg_restore.c         |   30 ++++++++++++++++++++
10 files changed, 184 insertions(+), 6 deletions(-)


Re: pgsql: Add --section option to pg_dump and pg_restore.

From
Thom Brown
Date:
On 17 December 2011 00:17, Andrew Dunstan <andrew@dunslane.net> wrote:
> Add --section option to pg_dump and pg_restore.
>
> Valid values are --pre-data, data and post-data. The option can be
> given more than once. --schema-only is equivalent to
> --section=pre-data --section=post-data. --data-only is equivalent
> to --section=data.

"Post-data items consist of definitions of indexes, triggers, rules
and constraints other than check constraints."

What about NOT VALID check constraints?  Those are required to be post-data.

--
Thom

Re: pgsql: Add --section option to pg_dump and pg_restore.

From
Andrew Dunstan
Date:

On 12/16/2011 07:57 PM, Thom Brown wrote:
> On 17 December 2011 00:17, Andrew Dunstan<andrew@dunslane.net>  wrote:
>> Add --section option to pg_dump and pg_restore.
>>
>> Valid values are --pre-data, data and post-data. The option can be
>> given more than once. --schema-only is equivalent to
>> --section=pre-data --section=post-data. --data-only is equivalent
>> to --section=data.
> "Post-data items consist of definitions of indexes, triggers, rules
> and constraints other than check constraints."
>
> What about NOT VALID check constraints?  Those are required to be post-data.
>


Hmm, yeah. Are they the only ones?

cheers

andrew

Re: pgsql: Add --section option to pg_dump and pg_restore.

From
Thom Brown
Date:
On 17 December 2011 02:32, Andrew Dunstan <andrew@dunslane.net> wrote:
>
>
> On 12/16/2011 07:57 PM, Thom Brown wrote:
>>
>> On 17 December 2011 00:17, Andrew Dunstan<andrew@dunslane.net>  wrote:
>>>
>>> Add --section option to pg_dump and pg_restore.
>>>
>>> Valid values are --pre-data, data and post-data. The option can be
>>> given more than once. --schema-only is equivalent to
>>> --section=pre-data --section=post-data. --data-only is equivalent
>>> to --section=data.
>>
>> "Post-data items consist of definitions of indexes, triggers, rules
>> and constraints other than check constraints."
>>
>> What about NOT VALID check constraints?  Those are required to be
>> post-data.
>>
>
>
> Hmm, yeah. Are they the only ones?

Well, there's object permissions too excluding ownership, but can't
think of anything else.

--
Thom

Re: pgsql: Add --section option to pg_dump and pg_restore.

From
Andrew Dunstan
Date:

On 12/17/2011 08:13 AM, Thom Brown wrote:
> On 17 December 2011 02:32, Andrew Dunstan<andrew@dunslane.net>  wrote:
>>
>> On 12/16/2011 07:57 PM, Thom Brown wrote:
>>> On 17 December 2011 00:17, Andrew Dunstan<andrew@dunslane.net>    wrote:
>>>> Add --section option to pg_dump and pg_restore.
>>>>
>>>> Valid values are --pre-data, data and post-data. The option can be
>>>> given more than once. --schema-only is equivalent to
>>>> --section=pre-data --section=post-data. --data-only is equivalent
>>>> to --section=data.
>>> "Post-data items consist of definitions of indexes, triggers, rules
>>> and constraints other than check constraints."
>>>
>>> What about NOT VALID check constraints?  Those are required to be
>>> post-data.
>>>
>>
>> Hmm, yeah. Are they the only ones?
> Well, there's object permissions too excluding ownership, but can't
> think of anything else.
>

I have qualified the sentence above to say that the exception is
"validated check constraints".

The comments in the code about when ACLs are dumped or restored appear
to be incorrect unless I'm missing something. The appear to be dumped
where they occur. (This code always makes my head hurt, I confess.)

cheers

andrew

Re: pgsql: Add --section option to pg_dump and pg_restore.

From
Thom Brown
Date:
On 17 December 2011 18:11, Andrew Dunstan <andrew@dunslane.net> wrote:
>
>
> On 12/17/2011 08:13 AM, Thom Brown wrote:
>>
>> On 17 December 2011 02:32, Andrew Dunstan<andrew@dunslane.net>  wrote:
>>>
>>>
>>> On 12/16/2011 07:57 PM, Thom Brown wrote:
>>>>
>>>> On 17 December 2011 00:17, Andrew Dunstan<andrew@dunslane.net>    wrote:
>>>>>
>>>>> Add --section option to pg_dump and pg_restore.
>>>>>
>>>>> Valid values are --pre-data, data and post-data. The option can be
>>>>> given more than once. --schema-only is equivalent to
>>>>> --section=pre-data --section=post-data. --data-only is equivalent
>>>>> to --section=data.
>>>>
>>>> "Post-data items consist of definitions of indexes, triggers, rules
>>>> and constraints other than check constraints."
>>>>
>>>> What about NOT VALID check constraints?  Those are required to be
>>>> post-data.
>>>>
>>>
>>> Hmm, yeah. Are they the only ones?
>>
>> Well, there's object permissions too excluding ownership, but can't
>> think of anything else.
>>
>
> I have qualified the sentence above to say that the exception is "validated
> check constraints".

Sounds good to me.

> The comments in the code about when ACLs are dumped or restored appear to be
> incorrect unless I'm missing something. The appear to be dumped where they
> occur. (This code always makes my head hurt, I confess.)

Dumped where they occur?  I'm not sure I follow.

--
Thom