2

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.

0

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

2
  • 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
0

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.

1
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy