search for: unique_viol

Displaying 4 results from an estimated 4 matches for "unique_viol".

2011 Dec 15
1
Quota PostgreSQL INSERT trigger
....bytes, messages = messages + NEW.messages WHERE username = NEW.username; IF found THEN RETURN NULL; END IF; BEGIN IF NEW.messages = 0 THEN RETURN NEW; ELSE NEW.messages = - NEW.messages; RETURN NEW; END IF; EXCEPTION WHEN unique_violation THEN -- someone just inserted the record, update it END; END LOOP; END; $$ LANGUAGE plpgsql; DROP TRIGGER IF EXISTS mergequota2 ON quota2; CREATE TRIGGER mergequota2 BEFORE INSERT ON quota2 FOR EACH ROW EXECUTE PROCEDURE merge_quota2(); --- Best regards, Adis
2015 Jul 24
0
possible patch for ACL SQL ERROR: duplicate key value violates unique constraint "user_shares_pkey"
...WHERE from_user = NEW.from_user AND to_user = NEW.to_user; IF found THEN -- updated and inserted RETURN NULL; END IF; BEGIN INSERT INTO user_shares (from_user,to_user,dummy) VALUES (NEW.from_user,NEW.to_user,NULL); --- return NULL; EXCEPTION WHEN unique_violation THEN -- someone just inserted the record, update it END; -- Update dummy after INSERT END LOOP; END; $$; CREATE TRIGGER insertsharing BEFORE INSERT ON user_shares FOR EACH ROW EXECUTE PROCEDURE insert_sharing(); - -- Steffen Kaiser -----BEGIN PGP SIGNATURE...
2009 Apr 29
1
Quota/Dict Postgres Trigger
I posted the trigger for v1.1 versions of Dovecot on the Wiki (http://wiki.dovecot.org/Quota/Dict ) and while I understand the comment posted about two process inserting at the same time, I'm not sure I understand how this is fixed in v1.2 other than via the revised trigger in the Wiki. Does someone have a known working trigger that will handle a double insert correctly? Also, out of
2015 Oct 16
0
quotas configuration a few questions
...W.messages = 0 THEN INSERT INTO quota (bytes, messages, username) VALUES (NEW.bytes, NULL, NEW.username); ELSE INSERT INTO quota (bytes, messages, username) VALUES (NEW.bytes, -NEW.messages, NEW.username); END IF; return NULL; EXCEPTION WHEN unique_violation THEN -- someone just inserted the record, update it END; END LOOP; END; $$ LANGUAGE plpgsql; DROP TRIGGER IF EXISTS mergequota ON quota; CREATE TRIGGER mergequota BEFORE INSERT ON quota FOR EACH ROW EXECUTE PROCEDURE merge_quota(); --(postgresql stuff)-- ============...