"invalid transaction termination" in Postgres when trying to update a value using a function
You can not commit in a trigger, and you forgot the return statement.
CREATE OR REPLACE FUNCTION increment_count() 
  RETURNS TRIGGER LANGUAGE plpgsql 
  AS $$
    BEGIN 
      UPDATE posts SET count=count+1 WHERE pid=NEW.pid;
      return null;
    END;
  $$;

In case of a BEFORE trigger, &quot;return NEW&quot; should be used!