Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gz3bj-0006Ey-LD for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Feb 2019 18:07:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gz3bi-0002KA-6D for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Feb 2019 18:07:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gz3bh-0002Jc-Qt for pgsql-hackers@lists.postgresql.org; Wed, 27 Feb 2019 18:07:01 +0000 Received: from mail-it1-x144.google.com ([2607:f8b0:4864:20::144]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gz3be-0007XQ-4q for pgsql-hackers@postgresql.org; Wed, 27 Feb 2019 18:07:00 +0000 Received: by mail-it1-x144.google.com with SMTP id w18so10601924itj.4 for ; Wed, 27 Feb 2019 10:06:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YxCHCEvdF4gTLNlOZET+5A619NhhS8tDSC3b5sjtDUI=; b=sSKBJ8uPq7x151NGTF9JjVCMrJNzrNH+1POfB7f5Jg2KiqLqwqeyqNVFEkIo5/MG9v hN1D+jnJchG2fmLT+5HiI3oUlGE5CKINi6YQOKjAyOpezjVCIRBndmCuOxXksRaXCT5y SItF5V59YrZfSy9g6Ds3LUICK0LPhwozpHXC/KA9pnz0YuEdhD6GopRkkl8bOegzweOD uF5tj7lFV9OOJ74NMwxD431ixIUJw2eQ7+JHgRy5LHAbyVSGQxZdu6mBBkk08b6dDX9E cEZmG8Sqi/eyoALaP4x4OxH8Y2GMD6N4QCN28498hM+oWkLBpzGUfeDyAnLT0HVwz6QT whZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YxCHCEvdF4gTLNlOZET+5A619NhhS8tDSC3b5sjtDUI=; b=X9geM8wunNurIUhozXnidbidEupCq4jemkb10pgzG6DjQW80cCr6xuXasrjKg+qkhP WFSvSCa7CMOsv0Sn7ZeNNOH2UNaJcaosiiTT9fhwN187o1ly0LY7BYfVjpsFQccR/lDo Xuu5TkLyyEZAJ60nLT7rkKxaS2TJM0P4rGOpMtuKpw7PJyABxleXvl3trsbcs/DI8yeE tGvQMjIEuhYJTwUTpWNYcnG8IRRfhZ0CtMwE80eWz3sNy6rP90+TluU3G5tYtXDwg/t3 Lgr7BD5q4eVaynnn9AdPku6cEqYYuIEOhUl4dihnUFDSH1CMRMYd5W9rxPF7KMcRxxSD c8zA== X-Gm-Message-State: AHQUAuZfyhkdZq/HqxL0l/5tzl/9krZlGvLCKwdKGVShE3tH6QBY7cxj VaVqkY1vzoVOtignTzto/GR2v+l/pDY= X-Google-Smtp-Source: AHgI3IZuLNX4IVcFUwbCuHaSJjlTRfAnKxoaHR08rm1d4qzCLOWEQ/bwzRZ2b5hBknZlPC2qdaJZ4Q== X-Received: by 2002:a24:47c9:: with SMTP id t192mr352523itb.64.1551290815584; Wed, 27 Feb 2019 10:06:55 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id y74sm1495241ita.12.2019.02.27.10.06.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 10:06:54 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id 9D65E800A28; Wed, 27 Feb 2019 12:06:53 -0600 (CST) Date: Wed, 27 Feb 2019 12:06:53 -0600 From: Justin Pryzby To: pgsql-hackers@postgresql.org Subject: Re: query logging of prepared statements Message-ID: <20190227180653.GF28750@telsasoft.com> References: <20190208132953.GF29720@telsasoft.com> <20190215145704.GW30291@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="r7U+bLA8boMOj+mD" Content-Disposition: inline In-Reply-To: <20190215145704.GW30291@telsasoft.com> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --r7U+bLA8boMOj+mD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 15, 2019 at 08:57:04AM -0600, Justin Pryzby wrote: > I propose that the prepared statement associated with an EXECUTE should be > included in log "DETAIL" only when log_error_verbosity=VERBOSE, for both SQL > EXECUTE and PQexecPrepared (if at all). I'd like to be able to continue > logging DETAIL (including bind parameters), so want like to avoid setting > "TERSE" just to avoid redundant messages. (It occurs to me that the GUC should > probably stick to its existing documented behavior rather than be extended, > which suggests that the duplicitive portions of the logs should simply be > removed, rather than conditionalized. Let me know what you think). I'm attaching a v2 patch which avoids repeated logging of PREPARE, rather than making such logs conditional on log_error_verbosity=VERBOSE, since log_error_verbosity is documented to control whether these are output: DETAIL/HINT/QUERY/CONTEXT/SQLSTATE. For SQL EXECUTE, excluding "detail" seems reasonable (perhaps for log_error_verbosity Date: Sat, 9 Feb 2019 19:20:43 -0500 Subject: [PATCH v2] Avoid repetitive log of PREPARE during EXECUTE of prepared statements --- src/backend/tcop/postgres.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 8b4d94c9a1..dac5362c81 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -1041,8 +1041,7 @@ exec_simple_query(const char *query_string) { ereport(LOG, (errmsg("statement: %s", query_string), - errhidestmt(true), - errdetail_execute(parsetree_list))); + errhidestmt(true))); was_logged = true; } @@ -2062,14 +2061,13 @@ exec_execute_message(const char *portal_name, long max_rows) if (check_log_statement(portal->stmts)) { ereport(LOG, - (errmsg("%s %s%s%s: %s", + (errmsg("%s %s%s%s", execute_is_fetch ? _("execute fetch from") : _("execute"), prepStmtName, *portal_name ? "/" : "", - *portal_name ? portal_name : "", - sourceText), + *portal_name ? portal_name : ""), errhidestmt(true), errdetail_params(portalParams))); was_logged = true; @@ -2150,15 +2148,14 @@ exec_execute_message(const char *portal_name, long max_rows) break; case 2: ereport(LOG, - (errmsg("duration: %s ms %s %s%s%s: %s", + (errmsg("duration: %s ms %s %s%s%s", msec_str, execute_is_fetch ? _("execute fetch from") : _("execute"), prepStmtName, *portal_name ? "/" : "", - *portal_name ? portal_name : "", - sourceText), + *portal_name ? portal_name : ""), errhidestmt(true), errdetail_params(portalParams))); break; -- 2.12.2 --r7U+bLA8boMOj+mD--