public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Paquier <[email protected]>
To: Philippe BEAUDOIN <[email protected]>
Cc: [email protected]
Subject: Re: pg_extension_config_dump() function and sequences
Date: Mon, 18 Jan 2016 15:10:42 +0900
Message-ID: <CAB7nPqS_v=s7L0jsx2bL1NYz8YocKQFcw4G2zZ_6e8H4NNpNUg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-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>


view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pg_extension_config_dump() function and sequences
  In-Reply-To: <CAB7nPqS_v=s7L0jsx2bL1NYz8YocKQFcw4G2zZ_6e8H4NNpNUg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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