Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-hackers by date

Next:From: Dimitri FontaineDate: 2008-04-03 13:17:23
Subject: COPY Transform support
Previous:From: Andrew DunstanDate: 2008-04-03 12:23:43
Subject: Re: modules

pgsql-patches by date

Next:From: Peter EisentrautDate: 2008-04-03 12:57:05
Subject: Re: psql command aliases support
Previous:From: Gregory StarkDate: 2008-04-03 09:54:48
Subject: Re: psql command aliases support

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group