Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-25-2008, 12:43 AM
Bruce Momjian
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

bruce wrote:
> Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > You are going to need to find community members who support your
> > > analysis if you want to make any headway in changing the patch.

> >
> > Let's turn that around, shall we? I think at this point it's *you*
> > that are standing alone and need to find someone who agrees with
> > your approach.

>
> I am confused exactly what people want changed in the patch. Some want
> no control over wrapping in file output, and others want $COLUMN to
> control column file output. The only person I am seeing code from is
> Greg Stark, but I think most don't want his changes.


Here is an email showing two people who want some way of getting wrapped
output into a file:

http://archives.postgresql.org/pgsql...4/msg00344.php

I think the API in the patch is the best I am going to do to keep
everyone happy --- 'wrapped' doesn't affect file/pipe output unless you
also tell it the width you want. Most interactive users are going to
set 'wrapped' and never set the width so it is automatically determined.

Some want wrapped to not affect file/pipe at all, while others (Greg
only?) want $COLUMNS to affect file/pipe output.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-25-2008, 12:43 AM
Gregory Stark
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

"Bruce Momjian" <bruce@momjian.us> writes:

> I think the API in the patch is the best I am going to do to keep
> everyone happy --- 'wrapped' doesn't affect file/pipe output unless you
> also tell it the width you want. Most interactive users are going to
> set 'wrapped' and never set the width so it is automatically determined.


Aaah, I think that's the key to where we're going wrong.

Trying to use the columns logic to encode two separate decisions. "wrapped or
not wrapped" and "how wide".

I think this also clarifies Tom's objection. He's worried about people
configuring psql for interactive use and being surprised when their automated
scripts fail to parse the resulting output.

We do need a way to specifically request wrapped format, but if we want a way
to say "wrapped format only on a terminal" then we should have a mode for that
too.

But once we're in wrapped format we should stick to it and always follow the
same logic to determine the width.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's Slony Replication support!

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-25-2008, 12:43 AM
Bruce Momjian
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

Gregory Stark wrote:
> "Bruce Momjian" <bruce@momjian.us> writes:
>
> > I think the API in the patch is the best I am going to do to keep
> > everyone happy --- 'wrapped' doesn't affect file/pipe output unless you
> > also tell it the width you want. Most interactive users are going to
> > set 'wrapped' and never set the width so it is automatically determined.

>
> Aaah, I think that's the key to where we're going wrong.
>
> Trying to use the columns logic to encode two separate decisions. "wrapped or
> not wrapped" and "how wide".


Well, they kind of fit because there is no good way to know the width
they would want for file/pipe output (no the terminal width isn't very
helpful in most cases). Bottom line is we are going to need a way to
specify the width for wrapped file/pipe (COLUMNS is not something that
is easily set), and \pset columns seems to allow both the setting of the
width and saying we want wrapping for file/pipe.

I am not excited about 'wrapped-interactive' and 'wrapped-all' formats.
Do you have some other idea in mind?

> I think this also clarifies Tom's objection. He's worried about people
> configuring psql for interactive use and being surprised when their automated
> scripts fail to parse the resulting output.
>
> We do need a way to specifically request wrapped format, but if we want a way
> to say "wrapped format only on a terminal" then we should have a mode for that
> too.
>
> But once we're in wrapped format we should stick to it and always follow the
> same logic to determine the width.


I can't think of any cases where we have one setting for interactive and
another for all uses.

I do think we might be adding an 'auto' format the does
aligned/wrapped/expanded based on the table width, but only for
interactive use.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-25-2008, 12:43 AM
Gregory Stark
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

"Bruce Momjian" <bruce@momjian.us> writes:

> I am not excited about 'wrapped-interactive' and 'wrapped-all' formats.
> Do you have some other idea in mind?


Some other idea for the name of it? Not particularly. I like your later
suggestion of "auto". Perhaps just "wrapped" and "auto"?

> I can't think of any cases where we have one setting for interactive and
> another for all uses.


In general I don't like such things but it seems to be what you're trying to
do. And also what Tom seems to be yearning for when he says that it shouldn't
affect file output. And if we do it we should do it properly and not hobble
both modes.

Note that basing it on the window size ioctl doesn't actually dtrt either.
What you really want is for it to depend on isatty(). If isatty(fout) is true
then you want to try to take the interactive default even if the ioctl fails.

Trying to join the two decisions means that nobody will be happy. If you ssh
in you won't get wrapped format, if you redirect to a file and specify wrapped
format explicitly you'll be frustrated that you're still not getting it. And
if you do want those things so you \pset columns you'll find it starts doing
it even when you -f file.dmp -- which doesn't seem bad to me but it means it
isn't satisfying your desires.

> I do think we might be adding an 'auto' format the does
> aligned/wrapped/expanded based on the table width, but only for
> interactive use.



--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's On-Demand Production Tuning

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-29-2008, 08:30 PM
Bruce Momjian
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

Gregory Stark wrote:
> "Bruce Momjian" <bruce@momjian.us> writes:
>
> > I am not excited about 'wrapped-interactive' and 'wrapped-all' formats.
> > Do you have some other idea in mind?

>
> Some other idea for the name of it? Not particularly. I like your later
> suggestion of "auto". Perhaps just "wrapped" and "auto"?


Well, I was going to bring up changes to the default after the patch was
applied but I will bring it up now. I think there is some real
attractivness to having long values wrap to fit on your screen in
interactive mode. In fact, it is hard to justify our current
interactive behavior of a row just overflowing the screen width and
moving to the next line. We have gotten used to it, but it is certainly
not very user-friendly.

We have discussed having a formatting mode where aligned output switches
to expanded output when the row is too wide. One idea would be to
create an 'auto' mode that would display in aligned, or wrapped if that
doesn't fit, or expanded if that doesn't fit.

However, this idea really doesn't help us with the file/pipe idea. One
crazy idea would be for formatting to take two values, like:

\pset formatting wrapped aligned

where the first is for interactive use and the second is for file/pipe
output. Now, if they only specify one value, what does that control?

> > I can't think of any cases where we have one setting for interactive and
> > another for all uses.

>
> In general I don't like such things but it seems to be what you're trying to
> do. And also what Tom seems to be yearning for when he says that it shouldn't
> affect file output. And if we do it we should do it properly and not hobble
> both modes.
>
> Note that basing it on the window size ioctl doesn't actually dtrt either.
> What you really want is for it to depend on isatty(). If isatty(fout) is true
> then you want to try to take the interactive default even if the ioctl fails.


Yes, we do that now with $COLUMNS.

> Trying to join the two decisions means that nobody will be happy. If you ssh
> in you won't get wrapped format, if you redirect to a file and specify wrapped
> format explicitly you'll be frustrated that you're still not getting it. And
> if you do want those things so you \pset columns you'll find it starts doing
> it even when you -f file.dmp -- which doesn't seem bad to me but it means it
> isn't satisfying your desires.


I think we need to honor $COLUMNS if ioctl() fails.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-29-2008, 08:30 PM
Bruce Momjian
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

Bruce Momjian wrote:
> > Trying to join the two decisions means that nobody will be happy. If you ssh
> > in you won't get wrapped format, if you redirect to a file and specify wrapped
> > format explicitly you'll be frustrated that you're still not getting it. And
> > if you do want those things so you \pset columns you'll find it starts doing
> > it even when you -f file.dmp -- which doesn't seem bad to me but it means it
> > isn't satisfying your desires.

>
> I think we need to honor $COLUMNS if ioctl() fails.


Clarification, honor $COLUMNS if ioctl() fails but only for interactive
mode.

If we can't make everyone happy we could just not add the patch. It
sounds crazy but we have had cases in the past where we couldn't get
concensus and we did nothing. Of course nothing is usually worse than
either option but groups behave in strange ways sometimes.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-29-2008, 08:30 PM
Joshua D. Drake
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

Bruce Momjian wrote:

> interactive mode. In fact, it is hard to justify our current
> interactive behavior of a row just overflowing the screen width and
> moving to the next line. We have gotten used to it, but it is certainly
> not very user-friendly.


+1

>
> We have discussed having a formatting mode where aligned output switches
> to expanded output when the row is too wide. One idea would be to
> create an 'auto' mode that would display in aligned, or wrapped if that
> doesn't fit, or expanded if that doesn't fit.
>
> However, this idea really doesn't help us with the file/pipe idea. One
> crazy idea would be for formatting to take two values, like:
>
> \pset formatting wrapped aligned


IMO we should never wrap file or pipe output. Once it leaves psql, it
should be up to whatever you pushed it through (file/pipe/script) to
handle formatting.

Sincerely,

Joshua D. Drake



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-29-2008, 08:30 PM
Bruce Momjian
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

Joshua D. Drake wrote:
> Bruce Momjian wrote:
> > We have discussed having a formatting mode where aligned output switches
> > to expanded output when the row is too wide. One idea would be to
> > create an 'auto' mode that would display in aligned, or wrapped if that
> > doesn't fit, or expanded if that doesn't fit.
> >
> > However, this idea really doesn't help us with the file/pipe idea. One
> > crazy idea would be for formatting to take two values, like:
> >
> > \pset formatting wrapped aligned

>
> IMO we should never wrap file or pipe output. Once it leaves psql, it
> should be up to whatever you pushed it through (file/pipe/script) to
> handle formatting.


Yes, I understand that argument, but the way we wrap values is something
an external tool is going to have great trouble duplicating.

For example, if I want to send wide psql output in email, right now I
just send it wide or use \x. With 'wrapped' I can set it to 72 columns
and get something I can email to people. I could copy it from my
screen, but if the output is more than a screen full it is much harder
to capture. (Yea, I could use 'script', but that isn't for the novice,
and I have no idea how that would be done on Win32.)

We could go with wrap only handling interactive and then see what
feedback we get from the field. For short output people can cut/paste
into files if they want wrapped output. That would eliminate the need
for \pset columns. We could just do ioctl() and check $COLUMNS.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-29-2008, 08:30 PM
Joshua D. Drake
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

Bruce Momjian wrote:

> For example, if I want to send wide psql output in email, right now I
> just send it wide or use \x. With 'wrapped' I can set it to 72 columns
> and get something I can email to people. I could copy it from my
> screen, but if the output is more than a screen full it is much harder
> to capture. (Yea, I could use 'script', but that isn't for the novice,
> and I have no idea how that would be done on Win32.)


I think your idea of novice is a little different than mine. A novice
isn't going to use this feature anyway, and by the time they start to
consider it (if they ever do), they will have already wrapped it in Perl
or C#.


Sincerely,

Joshua D. Drake

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-29-2008, 08:30 PM
Aidan Van Dyk
 
Posts: n/a
Default Re: Proposed patch - psql wraps at window width

* Bruce Momjian <bruce@momjian.us> [080424 23:14]:

> Well, I was going to bring up changes to the default after the patch was
> applied but I will bring it up now. I think there is some real
> attractivness to having long values wrap to fit on your screen in
> interactive mode. In fact, it is hard to justify our current
> interactive behavior of a row just overflowing the screen width and
> moving to the next line. We have gotten used to it, but it is certainly
> not very user-friendly.


-1.

Personally, I don't ever want to see that wrapped format.

<opinion valid="maybe not">
That wrapped format is more user-unfriendly than the long lines, which
are at least easily understandable.
</opinion>

So add a wrapped format, because obviously some people want it, but in a
similar vien to the making psql have no banner by default, I think
making wrapped format the default will cause much user consternation.

In Bruce's sample, even with the rules "right there", I still had to
look at the query to try and figure out what each data piece actually
was.

But I have to admit, trying to get a generic multi-column "wrapped"
format is a hard task. I couldn't come up with a scheme for showing it
easily myself on my (discarded) attempt to reply to the sample output.
Anything that *doesn't* have a wrapped line end with \ and then continue
with a > is going to feel awkward to me, and I'ld rather just have the
long lines, because having a one-off, complicated display format in
psql, even though it could technically define exactly what the data is
it's trying to display, if it's different from everything else means I'm
going to avoid it as much as possible.

a.
--
Aidan Van Dyk Create like a god,
aidan@highrise.ca command like a king,
http://www.highrise.ca/ work like a slave.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFIEdbyuVxNPsxNPScRAoBPAKCW8EvHIaQ3JWmbUppFu0 BiTArimQCgglxq
66Ay4GDqySJiYavAEV89GfY=
=avI6
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:19 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472