Thread: PostgreSQL Log Info
Is it possible to log the rows returned by a query in the PostgreSQL logs?
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
On Thursday, November 21, 2024, Jethish Jethish <jethish777@gmail.com> wrote: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.
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
On Fri, Nov 22, 2024, 10:49 AM David G. Johnston <david.g.johnston@gmail.com> wrote:On Thursday, November 21, 2024, Jethish Jethish <jethish777@gmail.com> wrote: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.
On Fri, Nov 22, 2024 at 01:02:27PM +0530, Jethish Jethish wrote: > 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 Please note that you wrote what you want to do. And David asked about use case. Which is different. Basically the question can be summed into: *why* you think you want that. I don't think anything even remotely similar to this exists. You could, of course, add it to Pg by changing sources (it is open source after all), but given that such feature would be downright dangerous for huge majority of situations, I don't expect it to become reality in mainline Pg. Best regards, depesz
Am Fri, Nov 22, 2024 at 01:02:27PM +0530 schrieb Jethish Jethish: > If an select query is fired I need the query returned values needs to be > 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
On 11/21/24 23:32, Jethish Jethish wrote: > 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 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 > <david.g.johnston@gmail.com <mailto:david.g.johnston@gmail.com>> wrote: > > On Thursday, November 21, 2024, Jethish Jethish > <jethish777@gmail.com <mailto:jethish777@gmail.com>> wrote: > > 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. > -- Adrian Klaver adrian.klaver@aklaver.com
If an select query is fired I need the query returned values needs to be logged in my PostgreSQL log file.
Sorry guys, what I meant was to log the tuple returned count not the values to get printed in logs.
On Fri, Nov 22, 2024 at 12:32 AM Jethish Jethish <jethish777@gmail.com> wrote:If an select query is fired I need the query returned values needs to be 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.
On 11/21/24 21:02, Jethish Jethish wrote: > Hi Everyone, > > Is it possible to log the rows returned by a query in the PostgreSQL logs? https://github.com/pgaudit/pgaudit/blob/main/README.md "pgaudit.log_rows Specifies that audit logging should include the number of rows retrieved or affected by a statement. When enabled the rows field will be included after the parameter field. The default is off." -- Adrian Klaver adrian.klaver@aklaver.com
Sorry guys, what I meant was to log the tuple returned count not the values to get printed in logs.