public inbox for [email protected]  
help / color / mirror / Atom feed
pg_extension_config_dump() function and sequences
5+ messages / 3 participants
[nested] [flat]

* pg_extension_config_dump() function and sequences
@ 2016-01-05 20:29 Philippe BEAUDOIN <[email protected]>
  2016-01-18 06:10 ` Re: pg_extension_config_dump() function and sequences Michael Paquier <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Philippe BEAUDOIN @ 2016-01-05 20:29 UTC (permalink / raw)
  To: pgsql-docs

Hi all,

The page "Packaging Related Objects into an Extension" has a third 
chapter dealing with "Extension Configuration Tables". A final paragraph 
would be useful to explain that:

The pg_extension_config_dump() function can also register sequences, so 
that the current properties of the registered sequences are saved by 
pg_dump and later restored. The function can support sequences either 
explicitely created with an ALTER SEQUENCE statement or implicitely 
created when a table contains SERIAL or BIGSERIAL columns. Note that the 
sequences associated to SERIAL or BIGSERIAL columns of a configuration 
table need to be registered using the pg_extension_config_dump() 
function if one wants to restore the properties they had at pg_dump time.

Sorry for my English. This has to be probably reworded a bit.

Best regards.
Philippe Beaudoin.


-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pg_extension_config_dump() function and sequences
  2016-01-05 20:29 pg_extension_config_dump() function and sequences Philippe BEAUDOIN <[email protected]>
@ 2016-01-18 06:10 ` Michael Paquier <[email protected]>
  2016-01-19 20:14   ` Re: pg_extension_config_dump() function and sequences Philippe BEAUDOIN <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Paquier @ 2016-01-18 06:10 UTC (permalink / raw)
  To: Philippe BEAUDOIN <[email protected]>; +Cc: pgsql-docs

On Wed, Jan 6, 2016 at 5:29 AM, Philippe BEAUDOIN <[email protected]> wrote:
> The page "Packaging Related Objects into an Extension" has a third chapter
> dealing with "Extension Configuration Tables". A final paragraph would be
> useful to explain that:
>
> The pg_extension_config_dump() function can also register sequences, so that
> the current properties of the registered sequences are saved by pg_dump and
> later restored. The function can support sequences either explicitely
> created with an ALTER SEQUENCE statement or implicitely created when a table
> contains SERIAL or BIGSERIAL columns. Note that the sequences associated to
> SERIAL or BIGSERIAL columns of a configuration table need to be registered
> using the pg_extension_config_dump() function if one wants to restore the
> properties they had at pg_dump time.

Instead of a single paragraph, perhaps we could make things more
generic like in the attached?
-- 
Michael


-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs


Attachments:

  [binary/octet-stream] extension-mark-seq-v1.patch (2.3K, 2-extension-mark-seq-v1.patch)
  download | inline diff:
diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml
index 4a88381..ff9c749 100644
--- a/doc/src/sgml/extend.sgml
+++ b/doc/src/sgml/extend.sgml
@@ -677,17 +677,21 @@ SET LOCAL search_path TO @extschema@;
 
     <para>
      To solve this problem, an extension's script file can mark a table
-     it has created as a configuration table, which will cause
-     <application>pg_dump</> to include the table's contents (not its
-     definition) in dumps.  To do that, call the function
+     or a sequence it has created as a configuration relation, which will
+     cause <application>pg_dump</> to include the table's or the sequence's
+     contents (not its definition) in dumps.  To do that, call the function
      <function>pg_extension_config_dump(regclass, text)</> after creating the
-     table, for example
+     table or the sequence, for example
 <programlisting>
 CREATE TABLE my_config (key text, value text);
+CREATE SEQUENCE my_config_seq;
 
 SELECT pg_catalog.pg_extension_config_dump('my_config', '');
+SELECT pg_catalog.pg_extension_config_dump('my_config_seq', '');
 </programlisting>
-     Any number of tables can be marked this way.
+     Any number of tables or sequences can be marked this way. Sequences
+     associated with <type>serial</> or <type>bigserial</> columns can
+     be marked as well.
     </para>
 
     <para>
@@ -709,6 +713,11 @@ SELECT pg_catalog.pg_extension_config_dump('my_config', 'WHERE NOT standard_entr
     </para>
 
     <para>
+     For sequences, the second argument of <function>pg_extension_config_dump</>
+     has no effect.
+    </para>
+
+    <para>
      More complicated situations, such as initially-provided rows that might
      be modified by users, can be handled by creating triggers on the
      configuration table to ensure that modified rows are marked correctly.
@@ -732,6 +741,12 @@ SELECT pg_catalog.pg_extension_config_dump('my_config', 'WHERE NOT standard_entr
      out but the dump will not be able to be restored directly and user
      intervention will be required.
     </para>
+    
+    <para>
+     Sequences associated with <type>serial</> or <type>bigserial</> columns
+     need to be directly marked to dump their state. Marking their parent
+     relation is not enough for this purpose.
+    </para>
    </sect2>
 
    <sect2>


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pg_extension_config_dump() function and sequences
  2016-01-05 20:29 pg_extension_config_dump() function and sequences Philippe BEAUDOIN <[email protected]>
  2016-01-18 06:10 ` Re: pg_extension_config_dump() function and sequences Michael Paquier <[email protected]>
@ 2016-01-19 20:14   ` Philippe BEAUDOIN <[email protected]>
  2016-04-18 03:17     ` Re: pg_extension_config_dump() function and sequences Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Philippe BEAUDOIN @ 2016-01-19 20:14 UTC (permalink / raw)
  To: Michael Paquier <[email protected]>; +Cc: pgsql-docs

Le 18/01/2016 07:10, Michael Paquier a écrit :
> On Wed, Jan 6, 2016 at 5:29 AM, Philippe BEAUDOIN <[email protected]> wrote:
>> The page "Packaging Related Objects into an Extension" has a third chapter
>> dealing with "Extension Configuration Tables". A final paragraph would be
>> useful to explain that:
>>
>> The pg_extension_config_dump() function can also register sequences, so that
>> the current properties of the registered sequences are saved by pg_dump and
>> later restored. The function can support sequences either explicitely
>> created with an ALTER SEQUENCE statement or implicitely created when a table
>> contains SERIAL or BIGSERIAL columns. Note that the sequences associated to
>> SERIAL or BIGSERIAL columns of a configuration table need to be registered
>> using the pg_extension_config_dump() function if one wants to restore the
>> properties they had at pg_dump time.
> Instead of a single paragraph, perhaps we could make things more
> generic like in the attached?
It looks much better, indeed.

Philippe.



-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pg_extension_config_dump() function and sequences
  2016-01-05 20:29 pg_extension_config_dump() function and sequences Philippe BEAUDOIN <[email protected]>
  2016-01-18 06:10 ` Re: pg_extension_config_dump() function and sequences Michael Paquier <[email protected]>
  2016-01-19 20:14   ` Re: pg_extension_config_dump() function and sequences Philippe BEAUDOIN <[email protected]>
@ 2016-04-18 03:17     ` Peter Eisentraut <[email protected]>
  2016-04-18 04:33       ` Re: pg_extension_config_dump() function and sequences Michael Paquier <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Peter Eisentraut @ 2016-04-18 03:17 UTC (permalink / raw)
  To: Philippe BEAUDOIN <[email protected]>; Michael Paquier <[email protected]>; +Cc: pgsql-docs

On 01/19/2016 03:14 PM, Philippe BEAUDOIN wrote:
> Le 18/01/2016 07:10, Michael Paquier a écrit :
>> On Wed, Jan 6, 2016 at 5:29 AM, Philippe BEAUDOIN <[email protected]>
>> wrote:

>>> The pg_extension_config_dump() function can also register sequences,
>>> so that
>>> the current properties of the registered sequences are saved by
>>> pg_dump and
>>> later restored. The function can support sequences either explicitely
>>> created with an ALTER SEQUENCE statement or implicitely created when
>>> a table
>>> contains SERIAL or BIGSERIAL columns. Note that the sequences
>>> associated to
>>> SERIAL or BIGSERIAL columns of a configuration table need to be
>>> registered
>>> using the pg_extension_config_dump() function if one wants to restore
>>> the
>>> properties they had at pg_dump time.
>> Instead of a single paragraph, perhaps we could make things more
>> generic like in the attached?
> It looks much better, indeed.

committed



-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pg_extension_config_dump() function and sequences
  2016-01-05 20:29 pg_extension_config_dump() function and sequences Philippe BEAUDOIN <[email protected]>
  2016-01-18 06:10 ` Re: pg_extension_config_dump() function and sequences Michael Paquier <[email protected]>
  2016-01-19 20:14   ` Re: pg_extension_config_dump() function and sequences Philippe BEAUDOIN <[email protected]>
  2016-04-18 03:17     ` Re: pg_extension_config_dump() function and sequences Peter Eisentraut <[email protected]>
@ 2016-04-18 04:33       ` Michael Paquier <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Michael Paquier @ 2016-04-18 04:33 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; +Cc: Philippe BEAUDOIN <[email protected]>; pgsql-docs

On Mon, Apr 18, 2016 at 12:17 PM, Peter Eisentraut <[email protected]> wrote:
> On 01/19/2016 03:14 PM, Philippe BEAUDOIN wrote:
>> Le 18/01/2016 07:10, Michael Paquier a écrit :
>>> On Wed, Jan 6, 2016 at 5:29 AM, Philippe BEAUDOIN <[email protected]>
>>> wrote:
>
>>>> The pg_extension_config_dump() function can also register sequences,
>>>> so that
>>>> the current properties of the registered sequences are saved by
>>>> pg_dump and
>>>> later restored. The function can support sequences either explicitely
>>>> created with an ALTER SEQUENCE statement or implicitely created when
>>>> a table
>>>> contains SERIAL or BIGSERIAL columns. Note that the sequences
>>>> associated to
>>>> SERIAL or BIGSERIAL columns of a configuration table need to be
>>>> registered
>>>> using the pg_extension_config_dump() function if one wants to restore
>>>> the
>>>> properties they had at pg_dump time.
>>> Instead of a single paragraph, perhaps we could make things more
>>> generic like in the attached?
>> It looks much better, indeed.
>
> committed

Thanks. I completely forgot this patch..
-- 
Michael


-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2016-04-18 04:33 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-01-05 20:29 pg_extension_config_dump() function and sequences Philippe BEAUDOIN <[email protected]>
2016-01-18 06:10 ` Michael Paquier <[email protected]>
2016-01-19 20:14   ` Philippe BEAUDOIN <[email protected]>
2016-04-18 03:17     ` Peter Eisentraut <[email protected]>
2016-04-18 04:33       ` Michael Paquier <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox