Proposal: new border setting in psql
Here is a simple select output.
darcy=# select title_id, title_name from title;
title_id | title_name
----------+------------
2 | Mrs
3 | Ms
4 | Miss
(3 rows)
Now I change the border.
darcy=# \pset border 2
Border style is 2.
darcy=# select title_id, title_name from title;
+----------+------------+
| title_id | title_name |
+----------+------------+
| 2 | Mrs |
| 3 | Ms |
| 4 | Miss |
+----------+------------+
(3 rows)
I would like to propose a new border setting.
darcy=# \pset border 3
Border style is 3.
darcy=# select title_id, title_name from title;
+----------+------------+
| title_id | title_name |
+==========+============+
| 2 | Mrs |
+----------+------------+
| 3 | Ms |
+----------+------------+
| 4 | Miss |
+----------+------------+
(3 rows)
The reason for this is to allow the output to be fed directly into any
system using Restructured text as described in
http://docutils.sourceforge.net/docs/user/rst/quickref.html.
If there is any interest I will submit patches for code and
documentation.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
"D'Arcy J.M. Cain" <darcy@druid.net> writes:
I would like to propose a new border setting.
That code is horrendously overcomplicated and unreadable already :-(
I'm not too eager to add more variants to it.
The reason for this is to allow the output to be fed directly into any
system using Restructured text as described in
http://docutils.sourceforge.net/docs/user/rst/quickref.html.
Is that *really* going to work? What about quoting/escaping
conventions?
Also, how many of those "any systems" actually exist? Markup
conventions are a dime a dozen.
On the whole I think it ought to be sufficient to support XML output
for people who want easily-machine-readable query output.
regards, tom lane
On Thu, 21 Aug 2008 15:03:23 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:
"D'Arcy J.M. Cain" <darcy@druid.net> writes:
I would like to propose a new border setting.
That code is horrendously overcomplicated and unreadable already :-(
I'm not too eager to add more variants to it.
Actually, I already made the code changes and they were surprisingly
simple.
The reason for this is to allow the output to be fed directly into any
system using Restructured text as described in
http://docutils.sourceforge.net/docs/user/rst/quickref.html.Is that *really* going to work? What about quoting/escaping
conventions?
ReST is pretty good with that stuff.
Also, how many of those "any systems" actually exist? Markup
conventions are a dime a dozen.
That I can't say. My impression was that it was reasonably well
known. However, while ReST was *my* reason for proposing this it was
also important to me that the format stand by itself. I think it
does. It also follows the documentation in that it is an extension to
border 2 but with more borders, just like border 2 is more than border
1, etc. It's a consistent progression.
On the whole I think it ought to be sufficient to support XML output
for people who want easily-machine-readable query output.
Perhaps. The problem is that it still means running it through an
external program. That's fine for scripted processes but not for ad
hoc queries.
Perhaps what we really need is the ability for users to install their
own formatting functions. After all, we can define everything else.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
Proposed formats don't look easier to read for humans.
I doubt that they are more common or easier to process by machines than just
COPY query TO STDOUT CSV;
The reason for this is to allow the output to be fed directly into any
system using Restructured text
The idea would be to use psql as backend for some other system?
Or what do you mean by fed directly?
On Thu, Aug 21, 2008 at 10:54 PM, D'Arcy J.M. Cain <darcy@druid.net> wrote:
Show quoted text
On Thu, 21 Aug 2008 15:03:23 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:"D'Arcy J.M. Cain" <darcy@druid.net> writes:
I would like to propose a new border setting.
That code is horrendously overcomplicated and unreadable already :-(
I'm not too eager to add more variants to it.Actually, I already made the code changes and they were surprisingly
simple.The reason for this is to allow the output to be fed directly into any
system using Restructured text as described in
http://docutils.sourceforge.net/docs/user/rst/quickref.html.Is that *really* going to work? What about quoting/escaping
conventions?ReST is pretty good with that stuff.
Also, how many of those "any systems" actually exist? Markup
conventions are a dime a dozen.That I can't say. My impression was that it was reasonably well
known. However, while ReST was *my* reason for proposing this it was
also important to me that the format stand by itself. I think it
does. It also follows the documentation in that it is an extension to
border 2 but with more borders, just like border 2 is more than border
1, etc. It's a consistent progression.On the whole I think it ought to be sufficient to support XML output
for people who want easily-machine-readable query output.Perhaps. The problem is that it still means running it through an
external program. That's fine for scripted processes but not for ad
hoc queries.Perhaps what we really need is the ability for users to install their
own formatting functions. After all, we can define everything else.-- D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Thu, 21 Aug 2008 23:22:28 +0300
"Asko Oja" <ascoja@gmail.com> wrote:
The idea would be to use psql as backend for some other system?
Or what do you mean by fed directly?
No, I meant that one would do any ad hoc query and cut and paste the
output directly into a tracking tool that supports ReST. As I
explained in another message though, this is a nice side effect for me
and is the reason that I have an interest in coding it but it really is
a logical extension of what we have anyway. Look how simple the
documentation change would be. If you left out the extra example it's
a one line difference.
Index: src/sgml/ref/psql-ref.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v
retrieving revision 1.209
diff -u -p -u -r1.209 psql-ref.sgml
--- src/sgml/ref/psql-ref.sgml 3 Jul 2008 03:37:16 -0000 1.209
+++ src/sgml/ref/psql-ref.sgml 21 Aug 2008 20:31:24 -0000
@@ -1570,7 +1570,7 @@ lo_import 152801
<acronym>HTML</acronym> mode, this will translate directly
into the <literal>border=...</literal> attribute, in the
others only values 0 (no border), 1 (internal dividing lines),
- and 2 (table frame) make sense.
+ 2 (table frame) and 3 (individual cells) make sense.
</para>
</listitem>
</varlistentry>
@@ -2973,6 +2973,22 @@ peter@localhost testdb=> <userinput>S
+-------+--------+
(4 rows)
+peter@localhost testdb=> <userinput>\pset border 3</userinput>
+Border style is 3.
+peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
++-------+--------+
+| first | second |
++=======+========+
+| 1 | one |
++-------+--------+
+| 2 | two |
++-------+--------+
+| 3 | three |
++-------+--------+
+| 4 | four |
++-------+--------+
+(4 rows)
+
peter@localhost testdb=> <userinput>\pset border 0</userinput>
Border style is 0.
peter@localhost testdb=> <userinput>SELECT * FROM my_table;</userinput>
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
"D'Arcy J.M. Cain" <darcy@druid.net> writes:
On Thu, 21 Aug 2008 23:22:28 +0300
"Asko Oja" <ascoja@gmail.com> wrote:The idea would be to use psql as backend for some other system?
Or what do you mean by fed directly?
No, I meant that one would do any ad hoc query and cut and paste the
output directly into a tracking tool that supports ReST.
There's still the question of whether this covers any needs that aren't
met just as well by XML or CSV output formats.
regards, tom lane
On Thu, 21 Aug 2008 20:36:51 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:
"D'Arcy J.M. Cain" <darcy@druid.net> writes:
No, I meant that one would do any ad hoc query and cut and paste the
output directly into a tracking tool that supports ReST.There's still the question of whether this covers any needs that aren't
met just as well by XML or CSV output formats.
Well, we could remove all the display formats except XML. After all,
it can always be converted to any other format. Of course we wouldn't
do that. User convenience is all I'm thinking of.
What do you think of the idea of allowing user defined display
functions? Of course, that's a much bigger job.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
Tom Lane escribi�:
"D'Arcy J.M. Cain" <darcy@druid.net> writes:
On Thu, 21 Aug 2008 23:22:28 +0300
"Asko Oja" <ascoja@gmail.com> wrote:The idea would be to use psql as backend for some other system?
Or what do you mean by fed directly?No, I meant that one would do any ad hoc query and cut and paste the
output directly into a tracking tool that supports ReST.There's still the question of whether this covers any needs that aren't
met just as well by XML or CSV output formats.
I think it does -- I used to use the Latex output format for easy cut'n
pasting. ReST sounds like it serves the same purpose. If I had had to
use conversion to XML, it would have been rather painful.
What I wonder is whether this should be a border setting or a format
setting.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
On Thu, 21 Aug 2008 21:19:58 -0400
Alvaro Herrera <alvherre@commandprompt.com> wrote:
Tom Lane escribió:
There's still the question of whether this covers any needs that aren't
met just as well by XML or CSV output formats.I think it does -- I used to use the Latex output format for easy cut'n
pasting. ReST sounds like it serves the same purpose. If I had had to
use conversion to XML, it would have been rather painful.
ReST is nice because it's almost plain text. In fact, a ReST document
source can easily be read raw.
What I wonder is whether this should be a border setting or a format
setting.
I don't see it as a format for two reasons. First, it isn't really a
different format. It's just the same format as "border 2" with a few
extra lines. Second, and following from the first, it's such a logical
progression from "border 0" to the proposed "border 3" that that syntax
makes more sense. In fact, the guide is inches away from describing
this behaviour already.
Besides, making it a border option adds 12 lines to the code, 5 of
which are blank. I wouldn't want to think about the changes if it was
a different setting.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
On Thu, Aug 21, 2008 at 11:18:24PM -0400, D'Arcy J.M. Cain wrote:
I think it does -- I used to use the Latex output format for easy cut'n
pasting. ReST sounds like it serves the same purpose. If I had had to
use conversion to XML, it would have been rather painful.ReST is nice because it's almost plain text. In fact, a ReST document
source can easily be read raw.
I presume by ReST you mean this:
http://docutils.sourceforge.net/rst.html
Just guessing though. It's not referenced in wikipedia under that
acronym.
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Show quoted text
Please line up in a tree and maintain the heap invariant while
boarding. Thank you for flying nlogn airlines.
On Fri, 22 Aug 2008 08:23:01 +0200
Martijn van Oosterhout <kleptog@svana.org> wrote:
On Thu, Aug 21, 2008 at 11:18:24PM -0400, D'Arcy J.M. Cain wrote:
ReST is nice because it's almost plain text. In fact, a ReST document
source can easily be read raw.I presume by ReST you mean this:
http://docutils.sourceforge.net/rst.html
Yes. See the original message in this thread.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
On Thu, 21 Aug 2008 21:04:07 -0400
"D'Arcy J.M. Cain" <darcy@druid.net> wrote:
There's still the question of whether this covers any needs that aren't
met just as well by XML or CSV output formats.Well, we could remove all the display formats except XML. After all,
it can always be converted to any other format. Of course we wouldn't
do that. User convenience is all I'm thinking of.
Well, Tom has raised a question about its need and Asko has questioned
whether it should be under a different setting but so far no one has
outright rejected the proposal. Does anyone else have an opinion? I am
attaching a patch for further review.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
Attachments:
border_change.diffapplication/octet-stream; name=border_change.diffDownload+48-20
D'Arcy J.M. Cain wrote:
On Thu, 21 Aug 2008 21:04:07 -0400
"D'Arcy J.M. Cain" <darcy@druid.net> wrote:There's still the question of whether this covers any needs that aren't
met just as well by XML or CSV output formats.Well, we could remove all the display formats except XML. After all,
it can always be converted to any other format. Of course we wouldn't
do that. User convenience is all I'm thinking of.Well, Tom has raised a question about its need and Asko has questioned
whether it should be under a different setting but so far no one has
outright rejected the proposal. Does anyone else have an opinion? I am
attaching a patch for further review.
In general I think I prefer machine readable formats to be produces by
the backend so they are available through all clients, not just psql.
That said, this has sufficiently low impact that I'm not going to be
vastly upset if we let it through.
I think we should probably confine ourselves to output formats that are
in very wide use or we'll be supporting a vast multitude. CSV and XML
both qualify here - not sure that ReST does.
cheers
andrew
Andrew Dunstan <andrew@dunslane.net> writes:
I think we should probably confine ourselves to output formats that are
in very wide use or we'll be supporting a vast multitude. CSV and XML
both qualify here - not sure that ReST does.
Yeah, that's the core of my objection.
Also, having now looked at the proposed patch, it seems clear that it
isn't addressing the issue of quoting/escaping at all; so I wonder how
this can be considered to be a safely machine-readable format.
In particular, the output seems to me to not even approximate the rules
laid down at
http://docutils.sourceforge.net/docs/user/rst/quickref.html
which among other things requires backslashing of literal asterisk,
backquote, vertical bar, and underscore in order to avoid textual data
looking like it matches the format's inline-markup constructs.
So, quite aside from the question of whether we care to support ReST,
my opinion is that this patch fails to do so, and a significantly more
invasive patch would be needed to do it.
regards, tom lane
On Sat, 23 Aug 2008 14:42:57 -0400
Andrew Dunstan <andrew@dunslane.net> wrote:
In general I think I prefer machine readable formats to be produces by
the backend so they are available through all clients, not just psql.
What do you mean by "machine readable?" XML?
That said, this has sufficiently low impact that I'm not going to be
vastly upset if we let it through.I think we should probably confine ourselves to output formats that are
in very wide use or we'll be supporting a vast multitude. CSV and XML
both qualify here - not sure that ReST does.
It isn't ReST. It just happens that this very simple and logical
progression of the border setting works for ReST. The display stands
on its own. This is not true of machine readable formats like XML. I
guess the question is, why border 2? Border 1 seems to be enough. In
fact border 0 has everything we absolutely need. Why have any borders?
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
On Sat, 23 Aug 2008 14:57:50 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:
Also, having now looked at the proposed patch, it seems clear that it
isn't addressing the issue of quoting/escaping at all; so I wonder how
this can be considered to be a safely machine-readable format.
It's not a machine readable format. It is a simple display with more
border lines. Just like "border 2" is like "border 1" with more border
lines. I'm just following the progression.
In particular, the output seems to me to not even approximate the rules
laid down at
http://docutils.sourceforge.net/docs/user/rst/quickref.html
And there is no reason that it should.
So, quite aside from the question of whether we care to support ReST,
my opinion is that this patch fails to do so, and a significantly more
invasive patch would be needed to do it.
I suppose it is my fault for mentioning ReST. That was the reason I
looked into this but that is not what the final proposal is. I too
would argue against making a munged output just to match one formatting
scheme. If I do a query and I need to modify it manually when I use it
in *any* third party program that's my personal issue. If "border 3"
happens to get me closer to my format that's great but it has to stand
on its own merit. I think that this proopsal does.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
On Sat, 2008-08-23 at 14:42 -0400, Andrew Dunstan wrote:
D'Arcy J.M. Cain wrote:
On Thu, 21 Aug 2008 21:04:07 -0400
"D'Arcy J.M. Cain" <darcy@druid.net> wrote:There's still the question of whether this covers any needs that aren't
met just as well by XML or CSV output formats.Well, we could remove all the display formats except XML. After all,
it can always be converted to any other format. Of course we wouldn't
do that. User convenience is all I'm thinking of.Well, Tom has raised a question about its need and Asko has questioned
whether it should be under a different setting but so far no one has
outright rejected the proposal. Does anyone else have an opinion? I am
attaching a patch for further review.In general I think I prefer machine readable formats to be produces by
the backend so they are available through all clients, not just psql.
ReST is both human-readable format and machine readable format.
Where should this come from ?
That said, this has sufficiently low impact that I'm not going to be
vastly upset if we let it through.I think we should probably confine ourselves to output formats that are
in very wide use or we'll be supporting a vast multitude. CSV and XML
both qualify here - not sure that ReST does.
ReST is just one variant of TEXT - also a format which is in very wide
use :)
I mean, XML is just a meta-format, like TEXT, unless we start to
formalize our XML, provide DTD-s, etc.
----------------
Hannu
On Sun, Aug 24, 2008 at 2:00 AM, D'Arcy J.M. Cain <darcy@druid.net> wrote:
On Sat, 23 Aug 2008 14:57:50 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:Also, having now looked at the proposed patch, it seems clear that it
isn't addressing the issue of quoting/escaping at all; so I wonder how
this can be considered to be a safely machine-readable format.It's not a machine readable format. It is a simple display with more
border lines. Just like "border 2" is like "border 1" with more border
lines. I'm just following the progression.
Personally I think it's rather nice to be able to have some extra
flexibility in how psql prints out data. Maybe, instead of the dry
and uninformative 'border 2', there could be a set of ouput control
options. Maybe I want the text aligned but with no border for
example.
merlin
On Sun, 24 Aug 2008 09:16:43 -0400
"Merlin Moncure" <mmoncure@gmail.com> wrote:
Personally I think it's rather nice to be able to have some extra
flexibility in how psql prints out data. Maybe, instead of the dry
and uninformative 'border 2', there could be a set of ouput control
options. Maybe I want the text aligned but with no border for
example.
You mean like "\pset border 0" does?
Personally I would love to see user defined display outputs for full
flexibility. Since we already have XML I would suggest using that as a
base and allow filters to process it before output.
That's a much larger job though.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
"D'Arcy J.M. Cain" <darcy@druid.net> writes:
On Sat, 23 Aug 2008 14:57:50 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:So, quite aside from the question of whether we care to support ReST,
my opinion is that this patch fails to do so, and a significantly more
invasive patch would be needed to do it.
I suppose it is my fault for mentioning ReST. That was the reason I
looked into this but that is not what the final proposal is.
Well, if you can't just paste your output into ReST without having to
hand-munge it afterwards, then ISTM the argument for having this
additional bit of complexity in our printing routines really falls flat.
regards, tom lane