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.

link|improve this question
feedback

2 Answers

up vote 0 down vote accepted

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

link|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
feedback

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.

link|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
feedback

Your Answer

 
or
required, but never shown