UPDATE OF on REPLICA TRIGGERS

2019-01-04 Thread PegoraroF10
We tried a lot, maybe for some days, to have some triggers working properly
on a replica server. So we read a discussion that is not possible to have
UPDATE OF in a trigger which works only on REPLICA. Our tests was production
using version 10 and replica using version 11.

I thing it would be helpful if the docs had this explained. Or an exception
would occur when we try to create a REPLICA TRIGGER with UPDATE OF.

Document it with something like ... replace your "UPDATE OF col1, col2" when
you create your trigger which works only on replica for "new.col1 is
distinct of old.col1" inside your trigger function.

CREATE OR REPLACE FUNCTION CalculateSomethingOnReplica() RETURNS TRIGGER AS
$$
BEGIN
  IF tg_op = 'update' THEN
IF new.col1 IS NOT DISTINCT FROM old.col1 THEN
  --DoTheCalc
END IF;
  END IF;
  RETURN NULL;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER CalculateSomethingOnReplica AFTER UPDATE ON MyTable FOR EACH
ROW EXECUTE PROCEDURE CalculateSomethingOnReplica();
ALTER TABLE MyTable ENABLE REPLICA TRIGGER CalculateSomethingOnReplica;



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-docs-f2165602.html



Re: Broken link in JSON Types documentation

2019-01-04 Thread Michael Paquier
On Wed, Jan 02, 2019 at 06:11:55PM -0500, Tom Lane wrote:
> In PG v10 and up this link goes to https://tools.ietf.org/html/rfc7159.
> Evidently whoever updated it didn't bother to back-patch into old
> branches.

I don't think that really cool to have user-facing documentation which
goes to the void on supported branches, especially if there is an
adequate replacement.  Tom, do you think that this is worth updating?
--
Michael


signature.asc
Description: PGP signature


Re: Broken link in JSON Types documentation

2019-01-04 Thread Tom Lane
Michael Paquier  writes:
> On Wed, Jan 02, 2019 at 06:11:55PM -0500, Tom Lane wrote:
>> In PG v10 and up this link goes to https://tools.ietf.org/html/rfc7159.
>> Evidently whoever updated it didn't bother to back-patch into old
>> branches.

> I don't think that really cool to have user-facing documentation which
> goes to the void on supported branches, especially if there is an
> adequate replacement.  Tom, do you think that this is worth updating?

I didn't quite have the energy to do something about it yesterday,
but if you do, feel free.

(I'd suggest looking up the commit that fixed it, to see if it fixed
anything else.)

regards, tom lane



Re: Broken link in JSON Types documentation

2019-01-04 Thread Michael Paquier
On Fri, Jan 04, 2019 at 09:50:34AM -0500, Tom Lane wrote:
> I didn't quite have the energy to do something about it yesterday,
> but if you do, feel free.
> 
> (I'd suggest looking up the commit that fixed it, to see if it fixed
> anything else.)

Sure, that was my plan.  The change is from d542859, which did not go
to 9.6 and older, and committed.  There was one conflict for libpq
which was simple enough to fix, and I have also double-checked the
rest of the docs for rogue links to RFCs.
--
Michael


signature.asc
Description: PGP signature