cbbrowne at ca.afilias.info cbbrowne
Mon Dec 13 04:02:45 PST 2004
> Marc,
>
> I wrote a little utility a while back that breaks up the Slony setup
> process into its three default component parts: tables with unique
> constraints, tables with no unique constraints, and sequences.
>
> The utility creates a slonik script broken into these three sections
> and automatically adds the table add key statements for tables for
> which it doesn't find a primary key.
>
> If the developers see any use in this, I'd be happy to contribute it to
> altperl. I'd also like suggestions for improvements!

There's already a script there called build_env.pl, originally by Joe
Kalash, which does much the same thing, albeit with some differences.

He has moved on to other things, so I'd be more than glad to see some
enhancements head in on this.

One thing that represents a "challenge" worth grappling with is the choice
of keys.  If you have a table with no primary key, but multiple "candidate
primary keys," it would be good to have a choice between them.  The answer
I'd like to see would be along the lines of it generating Slonik output
like:

  set add table (set id = 1, origin = 1, id = 127,
                 fully qualified name = 'public.ambiguous_table',
                 # uncomment one of the following:
                 # key = 'key_1'
                 # key = 'key_2'
                 # key = 'key_3'
   );

That way the "gentle user" may pick which of those keys they wish Slony-I
to use.

Alternatively, it could generate a "slon.env" style file thus:

  %KEYEDTABLES=(
                "public.ambiguous_table" =>
                # uncomment one of the following:
                        # 'key_1',
                        # 'key_2',
                        # 'key_3',
                "public.another_table" => 'single_key_candidate'
               );



More information about the Slony1-general mailing list