Re: Inserting from multiple processes? - Mailing list pgsql-general

From Dave Johansen
Subject Re: Inserting from multiple processes?
Date
Msg-id CAAcYxUfsktvRfyHY59pCu_SUNB+ayF9FdZUjhcqUEgeKcY-MGw@mail.gmail.com
Whole thread Raw
In response to Re: Inserting from multiple processes?  (Dave Johansen <davejohansen@gmail.com>)
Responses Re: Inserting from multiple processes?  (Francisco Olarte <folarte@peoplecall.com>)
List pgsql-general
On Tue, Jun 9, 2015 at 8:38 AM, Dave Johansen <davejohansen@gmail.com> wrote:
On Mon, Jun 8, 2015 at 10:15 AM, Dave Johansen <davejohansen@gmail.com>
For the sake of documentation, here's the function that I used to accomplish this:
CREATE FUNCTION insert_test_no_dup(tutc_ TIMESTAMP WITHOUT TIME ZONE, id_ INTEGER, value_ INTEGER) RETURNS VOID AS
$$
BEGIN
  BEGIN
    INSERT INTO test(tutc, id, value) VALUES (tutc_, id_, value_);
    RETURN;
  EXCEPTION WHEN unique_violation THEN
    -- do nothing because the record already exists
  END;
END;
$$
LANGUAGE plpgsql;

It appears that calling "SELECT insert_test_no_dup('2015-01-01', 1, 1)" cause the XID to increment? I'm not sure if it's only when the exception happens or all the time, but if there some way to prevent the increment of XID because it's causing problems with our system:
http://www.postgresql.org/message-id/CAAcYxUer3MA=enXvnOwe0oSAA8ComvxCF6OrHp-vUppr56twFg@mail.gmail.com

Thanks,
Dave

pgsql-general by date:

Previous
From: Gavin Flower
Date:
Subject: Re: Re: INSERT a real number in a column based on other columns OLD INSERTs
Next
From: 娄帅
Date:
Subject: Question about the isolation level and visible