1.96.  setaddsequence( integer, integer, text, text )

Propriétés de la fonction
Langage: PLPGSQL
Type du code retour: bigint

Sur le nœud origine pour l'ensemble set_id, ajoute la séquence seq_fqname à l'ensemble de réplication, et ajoute l'événement SET_ADD_SEQUENCE pour répliquer cet événement sur les nœuds abonnés.

declare
        p_set_id                        alias for $1;
        p_seq_id                        alias for $2;
        p_fqname                        alias for $3;
        p_seq_comment           alias for $4;
        v_set_origin            int4;
begin
        -- ----
        -- Grab the central configuration lock
        -- ----
        lock table sl_config_lock;

        -- ----
        -- Check that we are the origin of the set
        -- ----
        select set_origin into v_set_origin
                        from sl_set
                        where set_id = p_set_id;
        if not found then
                raise exception 'Slony-I: setAddSequence(): set % not found', p_set_id;
        end if;
        if v_set_origin != getLocalNodeId('_schemadoc') then
                raise exception 'Slony-I: setAddSequence(): set % has remote origin - submit to origin node', p_set_id;
        end if;

        if exists (select true from sl_subscribe
                        where sub_set = p_set_id)
        then
                raise exception 'Slony-I: cannot add sequence to currently subscribed set %',
                                p_set_id;
        end if;

        -- ----
        -- Add the sequence to the set and generate the SET_ADD_SEQUENCE event
        -- ----
        perform setAddSequence_int(p_set_id, p_seq_id, p_fqname,
                        p_seq_comment);
        return  createEvent('_schemadoc', 'SET_ADD_SEQUENCE',
                                                p_set_id::text, p_seq_id::text, 
                                                p_fqname::text, p_seq_comment::text);
end;