public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Q: limit the length of log file entries?
2+ messages / 1 participants
[nested] [flat]

* Re: Q: limit the length of log file entries?
@ 2025-09-04 15:54 Adrian Klaver <[email protected]>
  2025-09-04 18:21 ` Re: Q: limit the length of log file entries? Adrian Klaver <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Adrian Klaver @ 2025-09-04 15:54 UTC (permalink / raw)
  To: Albrecht Dreß <[email protected]>; Tom Lane <[email protected]>; +Cc: [email protected]

On 9/4/25 08:48, Albrecht Dreß wrote:
> Am 03.09.25 21:07 schrieb(en) Tom Lane:
>> There isn't any provision for limiting the length of source queries
>> quoted in the log.
> 
> I see, thanks for the clarification.  IMHO, it would be nice to have such an option, though…
> 
>> Had your user sent the bytea value as a query
>> parameter, then log_parameter_max_length[_on_error] would have
>> applied, but this looks like the value was just inline in the query.
> 
> I can confirm that the limitation is applied when I call PQexecParams() from a little c test application with the data included in the paramValues array.  The overlong log lines result from queries in a Python script using the psycopg2 module – no idea how this component formats the query.

The best explanation is found from the psycopg(3) docs:

https://www.psycopg.org/psycopg3/docs/basic/from_pg2.html

Differences from psycopg2

"Psycopg 3 sends the query and the parameters to the server separately, 
instead of merging them on the client side. Server-side binding works 
for normal SELECT and data manipulation statements (INSERT, UPDATE, 
DELETE), but it doesn’t work with many other statements. For instance, 
it doesn’t work with SET or with NOTIFY:"


> 
> Thanks again,
> Albrecht.


-- 
Adrian Klaver
[email protected]






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Q: limit the length of log file entries?
  2025-09-04 15:54 Re: Q: limit the length of log file entries? Adrian Klaver <[email protected]>
@ 2025-09-04 18:21 ` Adrian Klaver <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Adrian Klaver @ 2025-09-04 18:21 UTC (permalink / raw)
  To: Albrecht Dreß <[email protected]>; Tom Lane <[email protected]>; +Cc: [email protected]

On 9/4/25 08:54, Adrian Klaver wrote:
> On 9/4/25 08:48, Albrecht Dreß wrote:
>> Am 03.09.25 21:07 schrieb(en) Tom Lane:
>>> There isn't any provision for limiting the length of source queries
>>> quoted in the log.
>>
>> I see, thanks for the clarification.  IMHO, it would be nice to have 
>> such an option, though…
>>
>>> Had your user sent the bytea value as a query
>>> parameter, then log_parameter_max_length[_on_error] would have
>>> applied, but this looks like the value was just inline in the query.
>>
>> I can confirm that the limitation is applied when I call 
>> PQexecParams() from a little c test application with the data included 
>> in the paramValues array.  The overlong log lines result from queries 
>> in a Python script using the psycopg2 module – no idea how this 
>> component formats the query.
> 
> The best explanation is found from the psycopg(3) docs:
> 
> https://www.psycopg.org/psycopg3/docs/basic/from_pg2.html
> 
> Differences from psycopg2
> 
> "Psycopg 3 sends the query and the parameters to the server separately, 
> instead of merging them on the client side. Server-side binding works 
> for normal SELECT and data manipulation statements (INSERT, UPDATE, 
> DELETE), but it doesn’t work with many other statements. For instance, 
> it doesn’t work with SET or with NOTIFY:"

As example:

import psycopg2
import psycopg

conpsyc2 = psycopg2.connect("dbname=test user=postgres")
conpsyc3 = psycopg.connect("dbname=test user=postgres")

cur2 = conpsyc2.cursor()
cur3 = conpsyc3.cursor()

cur2.execute("select * from csv_test where id = %s", [1])
cur3.execute("select * from csv_test where id = %s", [1])

yields:

--cur2
2025-09-04 11:17:30.246 PDT [29695] postgres@test LOG:  statement: BEGIN
2025-09-04 11:17:30.246 PDT [29695] postgres@test LOG:  statement: 
select * from csv_test where id = 1

--cur3
2025-09-04 11:18:07.158 PDT [29703] postgres@test LOG:  statement: BEGIN
2025-09-04 11:18:07.159 PDT [29703] postgres@test LOG:  execute 
<unnamed>: select * from csv_test where id = $1
2025-09-04 11:18:07.159 PDT [29703] postgres@test DETAIL:  Parameters: 
$1 = '1'

> 
> 
>>
>> Thanks again,
>> Albrecht.
> 
> 


-- 
Adrian Klaver
[email protected]






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-09-04 18:21 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04 15:54 Re: Q: limit the length of log file entries? Adrian Klaver <[email protected]>
2025-09-04 18:21 ` Adrian Klaver <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox