public inbox for [email protected]  
help / color / mirror / Atom feed
From: Maiquel Grassi <[email protected]>
To: David Christensen <[email protected]>
To: Tom Lane <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Greg Sabino Mullane <[email protected]>
Cc: Jim Jones <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Adding comments to help understand psql hidden queries
Date: Tue, 1 Apr 2025 00:02:25 +0000
Message-ID: <CP4P284MB1968C2980DDC89049E619DD7ECAC2@CP4P284MB1968.BRAP284.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <CAHM0NXgs4-k3cSg2J0rJd2CPiT40ZfYGs4SK6MAHi-HB3B7dUA@mail.gmail.com>
References: <CAKAnmmJz8Hh=8Ru8jgzySPWmLBhnv4=oc_0KRiz-UORJ0Dex+w@mail.gmail.com>
	<CAHM0NXiD15-23=r1B9rHzKhS8e0+zwp_a6PncdLNetyF0xpNpA@mail.gmail.com>
	<[email protected]>
	<CAHM0NXheC3YO=ANPX0fCZKcQxMVBdgDzk9fc=-4TTCUN0aLYWA@mail.gmail.com>
	<[email protected]>
	<CAKAnmmL6-U+QPsuWM0r8mNq0Lo80d8L=cR7JLk7pypXJfwt=EA@mail.gmail.com>
	<CAHM0NXjO-Thdj+DqT5SOfLGVP-aVKhguiRfmkLDu4BJ_H-gg0A@mail.gmail.com>
	<CAKAnmmJq-13e74uSwDSnx0isA+9N0ByV+cscV4knpWo_mpM1FQ@mail.gmail.com>
	<CAHM0NXi5G9RwtH_MRQkh2jcZMvn8Uubm9pMn=KW-AuwYcNk51w@mail.gmail.com>
	<[email protected]>
	<CAHM0NXi19okhdByr6cNDwqHtjG7umjbY5OmRMwgropZHs01KGw@mail.gmail.com>
	<CAHM0NXhzU4oZJ00VUvbDL9gLoW2xUTLKZphoRCL3QWLGh5GE7A@mail.gmail.com>
	<[email protected]>
	<CAHM0NXgs4-k3cSg2J0rJd2CPiT40ZfYGs4SK6MAHi-HB3B7dUA@mail.gmail.com>

Hi!
I have read the discussion and would like
to share my humble opinion. I believe that
a visually appealing way to display the
output on the screen is to ensure symmetry
in the length of asterisks and description lines.
I imagine someone looking at the screen and
focusing on symmetrical details. Therefore,
the string length should serve as the basis for
the calculation. If the description length is an
even number, then the formula would be:

((description length − 7) / 2)​

Placing this result of asterisks on both sides of
the string ' QUERY ' ensures balance.
If the description length is an odd number,
then place:

((description length − 7) / 2)​
asterisks on the right side and:
(((description length − 7) / 2) ​+ 1)

asterisks on the left side.

This method does not always result in a perfectly
symmetric number of asterisks, but it provides a
more visually aligned appearance. At the end of
the SQL code, we should also include a line
terminator of the same length of the
description. The format looks like this:

/****************** QUERY *******************/
/* Get information about row-level policies */
SELECT pol.polname, pol.polpermissive,
CASE WHEN pol.polroles = '{0}' THEN NULL ELSE
pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles
where oid = any (pol.polroles) order by 1),',') END,
pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),
pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),
CASE pol.polcmd
WHEN 'r' THEN 'SELECT'
WHEN 'a' THEN 'INSERT'
WHEN 'w' THEN 'UPDATE'
WHEN 'd' THEN 'DELETE'
END AS cmd
FROM pg_catalog.pg_policy pol
WHERE pol.polrelid = '134384' ORDER BY 1;
/********************************************/

Regards,
Maiquel.


view thread (13+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Adding comments to help understand psql hidden queries
  In-Reply-To: <CP4P284MB1968C2980DDC89049E619DD7ECAC2@CP4P284MB1968.BRAP284.PROD.OUTLOOK.COM>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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