Re: psql \G command -- send query and output using extended format

From: "Dawid Kuroczko" <qnex42(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql \G command -- send query and output using extended format
Date: 2008-04-03 12:44:53
Message-ID: 758d5e7f0804030544g3132b33fo6730309e43b31c5e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Hi!

I have sent a patch to pgsql-patches:
http://archives.postgresql.org/pgsql-patches/2008-04/msg00050.php
...which adds \G command to psql client.

The idea of \G command is to perform the query, but with printing
query results using extended table output format.

For example:

postgres=# SELECT * FROM pg_stat_activity;
datid | datname | procpid | usesysid | usename |
current_query | waiting | xact_start |
query_start | backend_start |
client_addr | client_port
-------+----------+---------+----------+----------+---------------------------------+---------+-------------------------------+-------------------------------+-------------------------------+-------------+-------------
11511 | postgres | 11729 | 10 | postgres | SELECT * FROM
pg_stat_activity; | f | 2008-04-03 14:40:15.277272+02 |
2008-04-03 14:40:15.277272+02 | 2008-04-03 14:39:50.050512+02 |
| -1
(1 row)

postgres=# SELECT * FROM pg_stat_activity\G
-[ RECORD 1 ]-+-------------------------------
datid | 11511
datname | postgres
procpid | 11729
usesysid | 10
usename | postgres
current_query | SELECT * FROM pg_stat_activity
waiting | f
xact_start | 2008-04-03 14:41:47.533763+02
query_start | 2008-04-03 14:41:47.533763+02
backend_start | 2008-04-03 14:39:50.050512+02
client_addr |
client_port | -1

postgres=# SELECT * FROM pg_stat_activity\g
datid | datname | procpid | usesysid | usename |
current_query | waiting | xact_start |
query_start | backend_start |
client_addr | client_port
-------+----------+---------+----------+----------+--------------------------------+---------+-------------------------------+-------------------------------+-------------------------------+-------------+-------------
11511 | postgres | 11729 | 10 | postgres | SELECT * FROM
pg_stat_activity | f | 2008-04-03 14:42:09.940897+02 |
2008-04-03 14:42:09.940897+02 | 2008-04-03 14:39:50.050512+02 |
| -1
(1 row)

Comments anyone?

Regards,
Dawid

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2008-04-03 13:17:23 COPY Transform support
Previous Message Andrew Dunstan 2008-04-03 12:23:43 Re: modules

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2008-04-03 12:57:05 Re: psql command aliases support
Previous Message Gregory Stark 2008-04-03 09:54:48 Re: psql command aliases support