Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tepHj-00FsFc-Aj for pgsql-general@arkaria.postgresql.org; Mon, 03 Feb 2025 05:46:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tepHi-00AV4k-Dp for pgsql-general@arkaria.postgresql.org; Mon, 03 Feb 2025 05:46:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tepHi-00AV4c-32 for pgsql-general@lists.postgresql.org; Mon, 03 Feb 2025 05:46:14 +0000 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tepHd-002tX1-17 for pgsql-general@lists.postgresql.org; Mon, 03 Feb 2025 05:46:13 +0000 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-6efea3c9e6eso20281107b3.0 for ; Sun, 02 Feb 2025 21:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738561569; x=1739166369; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qY4VaRP/KneCr0IntKKA7H/5rLMA1RR1/Qlo79xPEz4=; b=OQLp3xWGQR59t83E1RLqMFlReYsmfBoXYlUews6GtZTwxvO3Du/UMT3R/uJrbvwF8J rkrQ6/NlPqJ/ZO6mZrpSdgO/yiFpJh0YWTz1pzEDYnexdRTdADRiKRhXEO4oDS7fy6sN 2lB62vxjaHyporrlchV2H1FUpYKnCUSmRm+bWGSY28XvXJPAKj+xSnJarD4lhx8RScBZ +cCZdU1UMQeByxmC+ek3ebHlB/vzIwAPJQnuDiHRtcyppffNpyAeWQydDYv7J+F0N94+ o6GpJ4sHCYpm+y+Kj7/3GFiUzetMNOgnoRAAdfyEfeqgzjOn8DBRoPM7CytD/d+VP64I +tVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738561569; x=1739166369; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qY4VaRP/KneCr0IntKKA7H/5rLMA1RR1/Qlo79xPEz4=; b=Mv9FxLMTkMlFfng2FXMtTfhBpw4uS5RBPg7qg0RpmV9M4f6v7QKXKFRzTgPI9vHPMP Z55GtkUnsJj9YQNOf+ZSxx4opDCKTfG8E2SVhXSqB6UuTvRQQOOTgiXMuQ0Gc93F62/y AI8Q3DuSsDrlF/j2/Y11oQopZE/L1xsqw86SympAhQsxgJTu2TGa5rbuTdDOfErhvD/3 m+qQwQ8UjcYJDZPpyztNFSOEKxbEyiVmNyGxxisj+1PD78zK4lIk4zZsAHy/2QbVUUd7 rWIQ8KUZH9ZGzIBFkf5XaGIMhq+A92alVDI4ZGgdsNX1Swf3HAtC7mrCwd3S9E3SHART 02YQ== X-Gm-Message-State: AOJu0Ywy78Dq9l6Q1+85znvx77pYUlL5z2hdOkJqtDo3V1BWiIr3x4kW ZWhFAjaJP4TbNdKYYn6atjiGGmAkSHA6RaBWWMatQ3DjSCY7Py+VYbHnEj/TsWA0w2o06S+vlHQ mzsfnn/D9iFHEnqYt+aKK7zOELk4= X-Gm-Gg: ASbGncvauR6AIJHX3djQGhTIiefMpbYNxcEuS3HaHseHInZA31RsBeNq1wF8xnmpNdD e2WaHH5S9pfxmLWAzJOgaHjW/kv/dbFw16lPHdvDaZNpfWau4/mqjrK3rsH3ddT69pT4uS3m3si +kzJilVCIqlWqFVeJI65icAmj9W/QJDA== X-Google-Smtp-Source: AGHT+IFRmYFOKBKO/0rQMj1NNpy4nFD4PdHuUrbEFOMvUkAn65429ubNC+ihBFG7grmcOsYZiyBQA6j5b1Sf7PdafkA= X-Received: by 2002:a05:690c:4b83:b0:6ef:6c57:ddb6 with SMTP id 00721157ae682-6f7a83fcfd1mr161038837b3.29.1738561568912; Sun, 02 Feb 2025 21:46:08 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Stehule Date: Mon, 3 Feb 2025 06:45:31 +0100 X-Gm-Features: AWEUYZlXAJvYYj0NPId0PZ0G9gnuhW_wJMZAuyr_RghBFR_IYITD7J0xrOGcI8c Message-ID: Subject: Re: Logging queries executed by SPI_execute To: Marcelo Fernandes Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000bc3ccf062d36687b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000bc3ccf062d36687b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi po 3. 2. 2025 v 0:06 odes=C3=ADlatel Marcelo Fernandes napsal: > Hi there, > > I have been trying to debug what queries an extension is firing. After > reading > the code for the extension, I noticed that all the statements are fired > via the > SPI interface, most specifically, using the SPI_execute* family of > functions. > > However, the problem is that these statements don't seem to feature in th= e > logfile. It has become a bit of a "dead end" for me to fully analyse what > queries are fired in the end. > > My postgresql.conf is fairly simple, but I have added "log_statement =3D > 'all'" > and thus was expecting to see information for these statements too. > > Is there anything I am missing? Some configuration or perhaps another way > to > find out about these statements? > > It may not be relevant, but the extension I am having a look at is > pg_repack if > anyone is interested. I am trying to get a deeper understanding of what t= he > function repack_apply does. > The queries executed by SPI are never executed on the top level. These queries are marked as nested. So you need to use auto_explain https://www.postgresql.org/docs/current/auto-explain.html with active auto_explain.log_nested_statements Regards Pavel > Thanks, > Marcelo. > > > --000000000000bc3ccf062d36687b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

po 3. 2. 2025= v=C2=A00:06 odes=C3=ADlatel Marcelo Fernandes <marcefern7@gmail.com> napsal:
Hi there,

I have been trying to debug what queries an extension is firing. After read= ing
the code for the extension, I noticed that all the statements are fired via= the
SPI interface, most specifically, using the SPI_execute* family of function= s.

However, the problem is that these statements don't seem to feature in = the
logfile. It has become a bit of a "dead end" for me to fully anal= yse what
queries are fired in the end.

My postgresql.conf is fairly simple, but I have added "log_statement = =3D 'all'"
and thus was expecting to see information for these statements too.

Is there anything I am missing? Some configuration or perhaps another way t= o
find out about these statements?

It may not be relevant, but the extension I am having a look at is pg_repac= k if
anyone is interested. I am trying to get a deeper understanding of what the=
function repack_apply does.

The queries= executed by SPI are never executed on the top level. These queries are mar= ked as nested.

So you need to use auto_explain= =C2=A0https://www.postgresql.org/docs/current/auto-explain.html with active= =C2=A0auto_explain= .log_nested_statements
<= code class=3D"gmail-varname">
Regards

Pavel
=C2=A0
Thanks,
Marcelo.


--000000000000bc3ccf062d36687b--