In PDB-4834 we added a log-queries config option which logs the AST & SQL produced as a result of queries PDB receives. It may be useful to have a way to correlate these logs with those in Postgres. One way of accomplishing this would be to have Postgres log the PDB uuid used for a query. Then using the Postgres log line prefix created by %c we could more easily correlate any logging on the Postgres side with those generated in PDB. Read here for more background on log_line_prefix in postgres. In the PDB code we would need to run `select pdb-uuid;` or a similar statement using the same connection as the SQL query to trigger postgres to log the PDB uuid with the %c id Postgres will add as a log line prefix. This would need to happen in query_eng.clj/stream-query-result and in query_eng.clj/produce-streaming-body. Notice in the 2nd link how we would need to do this in the inner `with-transacted-connection` form. This is due to PDB currently using two hikari connections per query as explained in PDB-4871. If this ticket is resolved you won't need to worry about the nested transactions using different connections. |