mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Add log_verbosity = 'silent' support to COPY command.
Previously, when the on_error option was set to ignore, the COPY command would always log NOTICE messages for input rows discarded due to data type incompatibility. Users had no way to suppress these messages. This commit introduces a new log_verbosity setting, 'silent', which prevents the COPY command from emitting NOTICE messages when on_error = 'ignore' is used, even if rows are discarded. This feature is particularly useful when processing malformed files frequently, where a flood of NOTICE messages can be undesirable. For example, when frequently loading malformed files via the COPY command or querying foreign tables using file_fdw (with an upcoming patch to add on_error support for file_fdw), users may prefer to suppress these messages to reduce log noise and improve clarity. Author: Atsushi Torikoshi Reviewed-by: Masahiko Sawada, Fujii Masao Discussion: https://postgr.es/m/ab59dad10490ea3734cf022b16c24cfd@oss.nttdata.com
This commit is contained in:
@@ -427,9 +427,11 @@ defGetCopyLogVerbosityChoice(DefElem *def, ParseState *pstate)
|
||||
char *sval;
|
||||
|
||||
/*
|
||||
* Allow "default", or "verbose" values.
|
||||
* Allow "silent", "default", or "verbose" values.
|
||||
*/
|
||||
sval = defGetString(def);
|
||||
if (pg_strcasecmp(sval, "silent") == 0)
|
||||
return COPY_LOG_VERBOSITY_SILENT;
|
||||
if (pg_strcasecmp(sval, "default") == 0)
|
||||
return COPY_LOG_VERBOSITY_DEFAULT;
|
||||
if (pg_strcasecmp(sval, "verbose") == 0)
|
||||
|
||||
@@ -1320,7 +1320,8 @@ CopyFrom(CopyFromState cstate)
|
||||
error_context_stack = errcallback.previous;
|
||||
|
||||
if (cstate->opts.on_error != COPY_ON_ERROR_STOP &&
|
||||
cstate->num_errors > 0)
|
||||
cstate->num_errors > 0 &&
|
||||
cstate->opts.log_verbosity >= COPY_LOG_VERBOSITY_DEFAULT)
|
||||
ereport(NOTICE,
|
||||
errmsg_plural("%llu row was skipped due to data type incompatibility",
|
||||
"%llu rows were skipped due to data type incompatibility",
|
||||
|
||||
Reference in New Issue
Block a user