okbob / pspg

Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exactly what data does pspg receive from psql?

velle opened this issue · comments

commented

Consider the following command:

$ psql -c "SELECT * FROM foo"
 gid | id |                                                                        geom                                                                        
-----+----+----------------------------------------------------------------------------------------------------------------------------------------------------
   1 |  1 | 01020000000400000000000000000024400000000000000000000000000000244000000000000049400000000000003440000000000000494000000000000034400000000000000000
   2 |  2 | 0102000000040000000000000000003E4000000000000000000000000000003E4000000000008051400000000000004940000000000080514000000000000049400000000000000000
(2 rows)

I can use pspg in two ways

  • $ psql -c "SELECT * FROM cubetown.LS_c" | pspg
  • $ PAGER=pspg psql -c "SELECT * FROM cubetown.LS_c"

Are they equivalent?

In both cases, does pgsg simply receive the output as a ascii-formatted table (using vertical pipe symbol, spaces and newlines)? Or does pspg receive the data in another format? Does the data received by pgps contain data (in addition to what I can see when printed directly to terminal), eg metadata such as datatype for each column that could hint how to format the data in the most user-friendly way?

I am asking about this in order to figure out, if I can customize pspg to do what I am trying to achieve :)

Sincerely