On Fri, Feb 14, 2025 at 1:03 AM Tom Lane <t...@sss.pgh.pa.us> wrote:
> =?UTF-8?B?0KHRgtC10L/QsNC9?= <slp...@gmail.com> writes: > > This patch adds the ability to log the types of parameters used in > queries > > when detailed query logging is enabled. > > If there's a patch in what you sent, I'm not seeing it. Looks like a > webpage dump or something. > > However, I suppose that it must add some catalog lookup operations to > the logging operations, and I'm feeling resistant to that, because of > the added cycles and risk-of-failure. I think you need to make a much > stronger case for the value of this information than you've done here. > > regards, tom lane > My apologies, it seems I am still experiencing some difficulty in accurately transmitting the code change details. I am re-submitting the diff.patch prepared by Stepan Neretin now, and will ensure the formatting is correct. Regarding your concerns, I understand your hesitation about adding catalog lookups due to potential performance impacts and failure risks. However, I believe that the benefits of including parameter types in detailed query logging will significantly outweigh the costs. Often, when analyzing problematic queries, we lack crucial information about the parameter types used. This lack of information forces us to request details from the client, which adds unnecessary delays and complexity to the debugging process. This patch addresses that directly. Best regards, Stepan Neretin
diff --git a/src/backend/nodes/params.c b/src/backend/nodes/params.c index 3acc7508e71..49df56f0135 100644 --- a/src/backend/nodes/params.c +++ b/src/backend/nodes/params.c @@ -21,11 +21,11 @@ #include "nodes/params.h" #include "parser/parse_node.h" #include "storage/shmem.h" +#include "utils/builtins.h" #include "utils/datum.h" #include "utils/lsyscache.h" #include "utils/memutils.h" - static void paramlist_parser_setup(ParseState *pstate, void *arg); static Node *paramlist_param_ref(ParseState *pstate, ParamRef *pref); @@ -367,9 +367,10 @@ BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen) ParamExternData *param = ¶ms->params[paramno]; appendStringInfo(&buf, - "%s$%d = ", + "%s$%d = (%s)", paramno > 0 ? ", " : "", - paramno + 1); + paramno + 1, + format_type_extended(param->ptype, -1, FORMAT_TYPE_ALLOW_INVALID)); if (param->isnull || !OidIsValid(param->ptype)) appendStringInfoString(&buf, "NULL");