Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to prevent Postgresql from logging ERRORs caused by attempted insertions where a UNIQUE KEY constraint is violated?

I could change the server_log_min directive, but this would disable all ERROR messages and not just those for UNIQUE KEY constraint.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

No. No such way exists. Short of piping logs via | grep -v ... | filter.

share|improve this answer
    
i guess i'll have to do some sort of log file post-processing... –  bugmenot77 Oct 1 '09 at 20:39
    
Actually. Anyone know if there's a way to specify piping via sed script through the conf file? –  bugmenot77 Jan 13 '10 at 23:50

There's no way to do this just by adjusting the logging mechanism on the server. You could do it by hacking the source code if you absolutely had to; the relevant code is in src/backend/access/nbtree/nbtinsert.c and looks like this, around line 300:

ereport(ERROR,
    (errcode(ERRCODE_UNIQUE_VIOLATION),
        errmsg("duplicate key value violates unique constraint \"%s\"",
            RelationGetRelationName(rel))));

You could change the log level there from ERROR to LOG or NOTICE.

share|improve this answer
    
thanks. i thought of hacking source code but it would end up being another maintenance nightmare! :) –  bugmenot77 Oct 1 '09 at 20:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.