On Fri, Feb 10, 2006 at 03:21:47PM -0500, Tom Lane wrote:
> I think it would be a good idea to expect this patch to cause zero
> change in psql output except in the cases where there are actually
> control characters in the data.  Otherwise there are likely to be
> complaints.  (I'm already unhappy at the prospect that this means
> every single regression test's output has changed, even if diff
> --ignore-space is hiding them.)
> I'd settle for stripping trailing blanks on the last line of a multiline
> field value, if that'd be any easier than stripping them for all lines.

Well, the attached patch removes the padding on the last column,
irrespective of the line. It will pad all the way to the end if the
cell is empty due to one of the earlier columns being multiline.

I did it this way because it's not always straight forward to know when
you're on the last line. In any case, this should bring all the
regression output back to the way it was. I didn't realise the
regression diffs ignored spaces...

As to the way the code is done, I prefer seperating out the test into a
variable because fitting it all on a single line is messy. OTOH, some
people discourage the use of ?: but I prefer it to a whole if

Have a nice day,
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
Index: src/bin/psql/print.c
RCS file: /projects/cvsroot/pgsql/src/bin/psql/print.c,v
retrieving revision 1.82
diff -u -r1.82 print.c
--- src/bin/psql/print.c        10 Feb 2006 22:29:06 -0000      1.82
+++ src/bin/psql/print.c        11 Feb 2006 23:23:15 -0000
@@ -573,6 +572,7 @@
                        for (j = 0; j < col_count; j++)
                                struct lineptr *this_line = col_lineptrs[j] + 
+                               int finalspaces = (opt_border != 2 && j == 
                                if (complete[j])  /* Just print spaces... */
                                        fprintf(fout, "%*s", widths[j], "");
@@ -602,7 +602,7 @@
                                                fprintf(fout, "%-s%*s", 
-                                                               widths[j] - 
this_line->width, "");
+                                                               finalspaces ? 0 
: (widths[j] - this_line->width), "");
                                        /* If at the right height, done this 
col */
                                        if (line_count == heights[j]-1 || 

Attachment: signature.asc
Description: Digital signature

Reply via email to