Subject: PostgreSQL Log Info

From: Jethish Jethish <[email-masked]>
Date: Fri, 22 Nov 2024 10:32:42 +0530

Hi Everyone,

Is it possible to log the rows returned by a query in the PostgreSQL logs?

---

From: "David G. Johnston" <[email-masked]>
Date: Thu, 21 Nov 2024 22:19:43 -0700

> Is it possible to log the rows returned by a query in the PostgreSQL logs?

As a practical matter, no.  That said, given one can get row contents into
the server log in various ways, what is the use case for why this
capability is thought to be needed?

David J.

---

From: Jethish Jethish <[email-masked]>
Date: Fri, 22 Nov 2024 13:02:27 +0530

Hi David,

If an select query is fired I need the query returned values needs to be
logged in my PostgreSQL log file.

For example if a select query returns 5 rows I need the same in the log
file

---

From: Ron Johnson <[email-masked]>
Date: Fri, 22 Nov 2024 04:07:44 -0500

Isn't "I need the query returned values" the purpose of the client
application?

On Fri, Nov 22, 2024 at 2:32 AM Jethish Jethish <[email-masked]>
wrote:

> On Fri, Nov 22, 2024, 10:49 AM David G. Johnston <
> [email-masked]> wrote:
>
>> As a practical matter, no.  That said, given one can get row contents
>> into the server log in various ways, what is the use case for why this

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

---

From: Karsten Hilbert <[email-masked]>
Date: Fri, 22 Nov 2024 12:35:55 +0100

> logged in my PostgreSQL log file.

What do you expect your log file to be in size after, say, a
day of activity ?

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B

---

From: Adrian Klaver <[email-masked]>
Date: Fri, 22 Nov 2024 08:02:54 -0800

> For example if a select query returns 5 rows I need the same in the log 

What if the query returns 500,000 rows?

What is the purpose of retaining this information?

> 
> 
> On Fri, Nov 22, 2024, 10:49 AM David G. Johnston 
> <[email-masked] <mailto:[email-masked]>> wrote:
> 
>     On Thursday, November 21, 2024, Jethish Jethish
>     <[email-masked] <mailto:[email-masked]>> wrote:
> 
>     As a practical matter, no.  That said, given one can get row
>     contents into the server log in various ways, what is the use case
>     for why this capability is thought to be needed?
> 
>     David J.
> 

-- 
Adrian Klaver
[email-masked]

---

From: "David G. Johnston" <[email-masked]>
Date: Fri, 22 Nov 2024 09:15:22 -0700

> logged in my PostgreSQL log file.
Then the answer is no, and unlikely to become a feature anyone would
develop or that we'd accept.

A more innovative solution is going to need to be thought up to
satisfy the security people that want to know what data was acquired from
their system by either their users or semi-privileged hackers (privileged
exploits would likely just disable such logging anyway).  The space of
setting up a proxy server in between clients and the PostgreSQL server is
under-explored as a means by which to incorporate such functionality
externally to the core server.

David J.

---

From: Jethish Jethish <[email-masked]>
Date: Fri, 22 Nov 2024 21:56:30 +0530

Sorry guys, what I meant was to log the tuple returned count not the values
to get printed in logs.

---

From: "David G. Johnston" <[email-masked]>
Date: Fri, 22 Nov 2024 09:34:18 -0700

On Fri, Nov 22, 2024 at 9:26 AM Jethish Jethish <[email-masked]>
wrote:

> Sorry guys, what I meant was to log the tuple returned count not the
> values to get printed in logs.
>
That too is a no.  Though more because is just doesn't seem useful enough
to expend effort on designing and implementing something.

There is a work-around in that you could enable auto-explain with analyze
and read the actuals from that.

David J.