Re: psql: Could we get "-- " prefixing on the **** QUERY **** outputs? (ECHO_HIDDEN)

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Kirk Wolak <wolakk(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: psql: Could we get "-- " prefixing on the **** QUERY **** outputs? (ECHO_HIDDEN)
Date: 2023-05-15 06:37:24
Message-ID: CAFj8pRCOBLnJ+H-gnw+y+X4xSjdJ2LiaBfii_qdCx92V7xZ0QQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

Dne po 15. 5. 2023 8:01 uživatel Kirk Wolak <wolakk(at)gmail(dot)com> napsal:

> This would be a trivial change. Willing to do it, and push it.
>
> In effect, we have this GREAT feature:
> \set ECHO_HIDDON on
>
> Which outputs a bunch of queries (as you all know).
> But somehow nobody thought that a user might want to paste ALL of the
> queries into their query editor, or even into another psql session, via (\e)
> and NOT get a ton of syntax errors?
>
> As an example: (added -- and a space)
>
> -- ********* QUERY **********
> SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered,
> i.indisvalid, pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),
> pg_catalog.pg_get_constraintdef(con.oid, true), contype, condeferrable,
> condeferred, i.indisreplident, c2.reltablespace
> FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i
> LEFT JOIN pg_catalog.pg_constraint con ON (conrelid = i.indrelid AND
> conindid = i.indexrelid AND contype IN ('p','u','x'))
> WHERE c.oid = '21949943' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
> ORDER BY i.indisprimary DESC, c2.relname;
> -- **************************
>
> -- ********* QUERY **********
> 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 = '21949943' ORDER BY 1;
> -- **************************
>
> Kirk...
>

This looks little bit strange

What about /* comments

Like

/******* Query ********/

Or just

-------- Query --------

Regards

Pavel

>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-05-15 07:04:44 Re: Bump MIN_WINNT to 0x0600 (Vista) as minimal runtime in 16~
Previous Message Hayato Kuroda (Fujitsu) 2023-05-15 06:29:49 RE: [PoC] pg_upgrade: allow to upgrade publisher node