Re: Adding comments to help understand psql hidden queries
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Sabino Mullane <htamfids@gmail.com>
Cc: Maiquel Grassi <grassi@hotmail.com.br>,
David Christensen <david+pg@pgguru.net>,
Peter Eisentraut <peter@eisentraut.org>,
Jim Jones <jim.jones@uni-muenster.de>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-23T17:35:04Z
Lists: pgsql-hackers
Attachments
- v8-0001-Add-comment-header-for-generated-SQL-inside-psql.patch (text/x-diff) patch v8-0001
- v8-0002-Improve-comment-headers-for-generated-SQL-inside-.patch (text/x-diff) patch v8-0002
Greg Sabino Mullane <htamfids@gmail.com> writes: > Going back through all the feedback and comments, plus having some time to > think things through, I am including a new patch, v7, that greatly > simplifies things, and only makes changes inside of describe.c. In the > spirit of not letting the perfect be the enemy of the good, I'm not > worrying at all about the number of stars, or the width, and simply adding > a small consistent description at the top of each query. I also realized > that having these queries show up in someone's server log could be quite > confusing, so I had them output as part of the query itself. In other > words, they show up in both psql -E and the server logs. I like this proposal quite a lot. It seems like about the right level of development/maintenance effort, and I think it provides a useful increment of usability. I have one slightly-orthogonal suggestion. I think that we should make the header for generated queries be different from that used for user queries in psql's logfile mode. Right now those are both /******** QUERY *********/ I propose instead printing /**** INTERNAL QUERY ****/ if it's a generated query. I went through the 0007 patch and made some editorial changes beyond that addition. I fixed a couple more internal queries to have headers (now each PSQLexec in describe.c has one). I also changed some of Greg's proposed headers in hopes of improving uniformity. Notably, I didn't like that some of the headers said "table" and some said "relation". I made them all say "table", although you could certainly argue for the opposite. This is all in-the-eye-of-the-beholder, so feel free to push back on any changes you don't like. For ease of review, v8-0001 attached is identical to Greg's 0007, and v8-0002 is my proposed changes on top of that. regards, tom lane
Commits
-
Add labels to help make psql's hidden queries more understandable.
- 41d69e6dccad 19 (unreleased) landed