psql Week 3 - Mailing list pgsql-hackers

From Peter Eisentraut
Subject psql Week 3
Date
Msg-id Pine.LNX.4.10.9910192107580.981-100000@peter-e.yi.org
Whole thread Raw
Responses Re: [HACKERS] psql Week 3  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
For external reasons I didn't get as much done as I wanted. Originally, I
planned for 4 weeks and I think I can keep that.

The source is posted at http://www.pathwaynet.com/~peter/psql3.tar.gz

CHANGELOG
* Accommodated object descriptions in \d* commands.
* Re-wrote \dd
* Re-wrote \d "table"
* \pset command as generic way for setting printing options (e.g., \pset format html, \pset null "(null)")
* Proliferated use of const char * and enums
* Rewrote \di, \dt, \ds, \dS. Say hello to \dv for views, which are now recognized correctly. You can also call, e.g.,
\dtvifor a list of indices, tables, and views. The possibilities are endless ... (where "endless" = 325)
 

Also I wrote new printing routines which are better abstracted so that one
could easily throw in new formats. Here are some examples. Let me know if
you hate them.

(Sorry that this is a little long.)

peter@localhost:5432 play=> \pset format aligned
peter@localhost:5432 play=> \pset border 0
peter@localhost:5432 play=> select * from foo;                 first      second   
-------- ------------      2       0 -----      0 hi     34      -1 -2        yo &&& <> ho
99999999 this is text
(7 rows)
peter@localhost:5432 play=> \pset border 1
peter@localhost:5432 play=> select * from foo; first   |    second    
----------+--------------       2 |        0 | -----       0 | hi      34 |       -1 | -2         | yo &&& <>
ho99999999| this is text
 
(7 rows)
peter@localhost:5432 play=> \pset border 2
peter@localhost:5432 play=> select * from foo;
+----------+--------------+
|  first   |    second    |
+----------+--------------+
|        2 |              |
|        0 | -----        |
|        0 | hi           |
|       34 |              |
|       -1 | -2           |
|          | yo &&& <> ho |
| 99999999 | this is text |
+----------+--------------+
(7 rows)
peter@localhost:5432 play=> \pset format unaligned
peter@localhost:5432 play=> \pset fieldsep ",,"
peter@localhost:5432 play=> select * from foo;
first,,second
2,,
0,,-----
0,,hi
34,,
-1,,-2
,,yo &&& <> ho
99999999,,this is text
(7 rows)
peter@localhost:5432 play=> \t
Turned on only tuples
peter@localhost:5432 play=> \x
Turned on expanded table representation
peter@localhost:5432 play=> select * from foo;

first,,2
second,,

first,,0
second,,-----

first,,0
second,,hi

first,,34
second,,

first,,-1
second,,-2

first,,
second,,yo &&& <> ho

first,,99999999
second,,this is text
peter@localhost:5432 play=> \pset border 1
peter@localhost:5432 play=> \pset format html
peter@localhost:5432 play=> \pset expanded
Turned off expanded display
peter@localhost:5432 play=> select * from foo;
<table border=1> <tr valign=top>   <td align=right>2</td>   <td align=left> </td> </tr> <tr valign=top>   <td
align=right>0</td>  <td align=left>-----</td> </tr> <tr valign=top>   <td align=right>0</td>   <td align=left>hi</td>
</tr><tr valign=top>   <td align=right>34</td>   <td align=left> </td> </tr> <tr valign=top>   <td
align=right>-1</td>  <td align=left>-2</td> </tr> <tr valign=top>   <td align=right> </td>   <td align=left>yo
&&&<> ho</td> </tr> <tr valign=top>   <td align=right>99999999</td>   <td align=left>this is
text</td></tr>
 
</table>
peter@localhost:5432 play=> \t
Turned off only tuples
peter@localhost:5432 play=> \pset border 2
peter@localhost:5432 play=> \pset null "(null)"
peter@localhost:5432 play=> \pset format latex
peter@localhost:5432 play=> select * from foo;
\begin{tabular}{|r|l|}
\hline
first & second \\
\hline
2 & (null) \\
0 & ----- \\
0 & hi \\
34 & (null) \\
-1 & -2 \\
(null) & yo &&& <> ho \\       % Yes, this needs to be escaped.
99999999 & this is text \\
\hline
\end{tabular}

(7 rows) \\
peter@localhost:5432 play=> \pset null
Current null display is "(null)".
peter@localhost:5432 play=> \pset fieldsep
Current field separator is ",,".


(Oh, you actually read all the way down to here? Good.)

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



pgsql-hackers by date:

Previous
From: Mike Mascari
Date:
Subject: Re: [HACKERS] Re: [BUGS] Postgres problems with 6.4 / 6.5 (fwd)
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] psql Week 3