argtypes[2] = INT8OID;
snprintf(query,1023,"select %s.sequenceSetValue($1," \
- "$2,NULL,$3); ",tg->tg_trigger->tgargs[0]);
+ "$2,NULL,$3,true); ",tg->tg_trigger->tgargs[0]);
plan = SPI_prepare(query,3,argtypes);
if ( plan == NULL )
{
-- ----------------------------------------------------------------------
-- FUNCTION sequenceSetValue (seq_id, seq_origin, ev_seqno, last_value)
-- ----------------------------------------------------------------------
-create or replace function @NAMESPACE@.sequenceSetValue(p_seq_id int4, p_seq_origin int4, p_ev_seqno int8, p_last_value int8) returns int4
+create or replace function @NAMESPACE@.sequenceSetValue(p_seq_id int4, p_seq_origin int4, p_ev_seqno int8, p_last_value int8,p_ignore_missing bool) returns int4
as $$
declare
v_fqname text;
+ v_found integer;
begin
+
-- ----
-- Get the sequences fully qualified name
-- ----
and SQ.seq_reloid = PGC.oid
and PGC.relnamespace = PGN.oid;
if not found then
+ if p_ignore_missing then
+ return null;
+ end if;
raise exception 'Slony-I: sequenceSetValue(): sequence % not found', p_seq_id;
end if;
return p_seq_id;
end;
$$ language plpgsql;
-comment on function @NAMESPACE@.sequenceSetValue(p_seq_id int4, p_seq_origin int4, p_ev_seqno int8, p_last_value int8) is
-'sequenceSetValue (seq_id, seq_origin, ev_seqno, last_value)
+comment on function @NAMESPACE@.sequenceSetValue(p_seq_id int4, p_seq_origin int4, p_ev_seqno int8, p_last_value int8,p_ignore_missing bool) is
+'sequenceSetValue (seq_id, seq_origin, ev_seqno, last_value,ignore_missing)
Set sequence seq_id to have new value last_value.
';
char *seq_relname = PQgetvalue(res1, tupno1, 3);
(void) slon_mkquery(&query,
- "select %s.sequenceSetValue(%s,%d,'%s','%s'); ",
+ "select %s.sequenceSetValue(%s,%d,'%s','%s',false); ",
rtcfg_namespace,
seql_seqid, node->no_id, seqbuf, seql_last_value);
start_monitored_event(&pm);