Commit Graph

167 Commits

Author SHA1 Message Date
Andrew Dunstan 7655f4ccea Add a pager_min_lines setting to psql
If set, the pager will not be used unless this many lines are to be
displayed, even if that is more than the screen depth. Default is zero,
meaning it's disabled.

There is probably more work to be done in giving the user control over
when the pager is used, particularly when wide output forces use of the
pager regardless of how many lines there are, but this is a start.
2015-03-28 11:07:41 -04:00
Peter Eisentraut 16bbb96a2b Fix whitespace 2015-03-27 19:50:55 -04:00
Bruce Momjian 376a0c4547 psql: show proper row count in \x mode for zero-column output
Also, fix pager enable selection for such cases, and other cleanups for
zero-column output.

Report by Thom Brown
2015-03-24 21:04:10 -04:00
Bruce Momjian 4baaf863ec Update copyright for 2015
Backpatch certain files through 9.0
2015-01-06 11:43:47 -05:00
Andrew Dunstan 4077fb4d1d Fix an error in psql that overcounted output lines.
This error counted the first line of a cell as "extra". The effect was
to cause far too frequent invocation of the pager. In most cases this
can be worked around (for example, by using the "less" pager with the -F
flag), so don't backpatch.
2014-11-21 12:37:09 -05:00
Stephen Frost a2dabf0e1d Add unicode_{column|header|border}_style to psql
With the unicode linestyle, this adds support to control if the
column, header, or border style should be single or double line
unicode characters.  The default remains 'single'.

In passing, clean up the border documentation and address some
minor formatting/spelling issues.

Pavel Stehule, with some additional changes by me.
2014-09-12 12:04:37 -04:00
Stephen Frost 82962838d4 Handle border = 3 in expanded mode
In psql, expanded mode was not being displayed correctly when using
the normal ascii or unicode linestyles and border set to '3'.  Now,
per the documentation, border '3' is really only sensible for HTML
and LaTeX formats, however, that's no excuse for ascii/unicode to
break in that case, and provisions had been made for psql to cleanly
handle this case (and it did, in non-expanded mode).

This was broken when ascii/unicode was initially added a good five
years ago because print_aligned_vertical_line wasn't passed in the
border setting being used by print_aligned_vertical but instead was
given the whole printTableContent.  There really isn't a good reason
for vertical_line to have the entire printTableContent structure, so
just pass in the printTextFormat and border setting (similar to how
this is handled in horizontal_line).

Pointed out by Pavel Stehule, fix by me.

Back-patch to all currently-supported versions.
2014-09-12 11:11:53 -04:00
Peter Eisentraut 3feda1bcbb Fix whitespace 2014-08-21 21:37:41 -04:00
Greg Stark 458ef6bad1 Fix further concerns about psql wrapping in expanded mode having
collateral damage on other formats, by Sergey Muraviov.
2014-08-18 12:20:32 +01:00
Bruce Momjian 0a78320057 pgindent run for 9.4
This includes removing tabs after periods in C comments, which was
applied to back branches, so this change should not effect backpatching.
2014-05-06 12:12:18 -04:00
Tom Lane 5358bfdc98 Fix uninitialized-variable warnings induced by recent commit. 2014-04-30 11:15:15 -04:00
Peter Eisentraut 322173eb0a Fix whitespace 2014-04-29 21:35:07 -04:00
Greg Stark dbe31616c9 Remove unnecessary cast causing a warning
Incidentally, I reversed the two names in the earlier commit. The
original author was Sergey Muraviov and the reviewer was Emre
Hasegeli.
2014-04-29 12:43:03 +01:00
Greg Stark 6513633b94 Add support for wrapping to psql's "extended" mode. This makes it very
feasible to display tables that have both many columns and some large
data in some columns (such as pg_stats).

Emre Hasegeli with review and rewriting from Sergey Muraviov and
reviewed by Greg Stark
2014-04-28 18:41:36 +01:00
Bruce Momjian 7e04792a1c Update copyright for 2014
Update all files in head, and files COPYRIGHT and legal.sgml in all back
branches.
2014-01-07 16:05:30 -05:00
Tom Lane 92459e7a7f Fix translatability markings in psql, and add defenses against future bugs.
Several previous commits have added columns to various \d queries without
updating their translate_columns[] arrays, leading to potentially incorrect
translations in NLS-enabled builds.  Offenders include commit 893686762
(added prosecdef to \df+), c9ac00e6e (added description to \dc+) and
3b17efdfd (added description to \dC+).  Fix those cases back to 9.3 or
9.2 as appropriate.

Since this is evidently more easily missed than one would like, in HEAD
also add an Assert that the supplied array is long enough.  This requires
an API change for printQuery(), so it seems inappropriate for back
branches, but presumably all future changes will be tested in HEAD anyway.

In HEAD and 9.3, also clean up a whole lot of sloppiness in the emitted
SQL for \dy (event triggers): lack of translatability due to failing to
pass words-to-be-translated through gettext_noop(), inadequate schema
qualification, and sloppy formatting resulting in unnecessarily ugly
-E output.

Peter Eisentraut and Tom Lane, per bug #8702 from Sergey Burladyan
2014-01-04 16:05:16 -05:00
Bruce Momjian 601f48076f psql: honor 'footer' option for expanded output
"No rows" previously only honored the tuples-only option.

Per report from Eli Mesika
2013-09-10 19:07:06 -04:00
Bruce Momjian 9af4159fce pgindent run for release 9.3
This is the first run of the Perl-based pgindent script.  Also update
pgindent instructions.
2013-05-29 16:58:43 -04:00
Tom Lane da5aeccf64 Move pqsignal() to libpgport.
We had two copies of this function in the backend and libpq, which was
already pretty bogus, but it turns out that we need it in some other
programs that don't use libpq (such as pg_test_fsync).  So put it where
it probably should have been all along.  The signal-mask-initialization
support in src/backend/libpq/pqsignal.c stays where it is, though, since
we only need that in the backend.
2013-03-17 12:06:42 -04:00
Peter Eisentraut 0343a59d11 psql: Improve unaligned expanded output for zero rows
This used to erroneously print an empty line.  Now it prints nothing.
2013-02-09 00:11:58 -05:00
Peter Eisentraut 8ade58a4ea psql: Improve expanded print output in tuples-only mode
When there are zero result rows, in expanded mode, "(No rows)" is
printed.  So far, there was no way to turn this off.  Now, when
tuples-only mode is turned on, nothing is printed in this case.
2013-02-09 00:11:58 -05:00
Bruce Momjian 530bbfac57 Rename new latex longtable function name, for consistency 2013-01-18 14:02:58 -05:00
Bruce Momjian 74a82bafe4 psql latex fixes
Remove extra line at bottom of table for new 'latex' mode border=3.
Also update 'latex'-longtable 'tableattr' docs to say
'whitespace-separated' instead of 'space'.
2013-01-18 08:30:31 -05:00
Bruce Momjian b14f81bc9a Add a latex-longtable output format to psql
latex longtable is more powerful than the 'tabular' output format
'latex' uses.  Also add border=3 support to 'latex'.
2013-01-17 11:39:38 -05:00
Bruce Momjian bd61a623ac Update copyrights for 2013
Fully update git head, and update back branches in ./COPYRIGHT and
legal.sgml files.
2013-01-01 17:15:01 -05:00
Tom Lane a563d94180 Standardize naming of malloc/realloc/strdup wrapper functions.
We had a number of variants on the theme of "malloc or die", with the
majority named like "pg_malloc", but by no means all.  Standardize on the
names pg_malloc, pg_malloc0, pg_realloc, pg_strdup.  Get rid of pg_calloc
entirely in favor of using pg_malloc0.

This is an essentially cosmetic change, so no back-patch.  (I did find
a couple of places where psql and pg_dump were using plain malloc or
strdup instead of the pg_ versions, but they don't look significant
enough to bother back-patching.)
2012-10-02 15:35:48 -04:00
Bruce Momjian 927d61eeff Run pgindent on 9.2 source tree in preparation for first 9.3
commit-fest.
2012-06-10 15:20:04 -04:00
Robert Haas 9b7a84f2a4 Tweak psql to print row counts when \x auto chooses non-expanded output.
Noah Misch
2012-05-01 16:05:01 -04:00
Peter Eisentraut 598bb8cdbd psql: Remove inappropriate const qualifiers
Since mbvalidate() can alter the string it validates, having the
callers claim that the strings they accept are const is inappropriate.
2012-03-16 20:35:00 +02:00
Peter Eisentraut 410ee35ed0 psql: Remove useless code
Apparently a copy-and-paste mistake introduced in
8ddd22f245.

found by Coverity
2012-03-08 23:15:03 +02:00
Peter Eisentraut 1673122127 psql: Fix memory leak
In expanded auto mode, a lot of allocated memory was not cleaned up.

found by Coverity
2012-03-07 23:52:15 +02:00
Peter Eisentraut 561ec76133 psql: Fix invalid memory access
Due to an apparent thinko, when printing a table in expanded mode
(\x), space would be allocated for 1 slot plus 1 byte per line,
instead of 1 slot per line plus 1 slot for the NULL terminator.  When
the line count is small, reading or writing the terminator would
therefore access memory beyond what was allocated.
2012-03-07 23:46:41 +02:00
Peter Eisentraut 169c8a9112 psql: Support zero byte field and record separators
Add new psql settings and command-line options to support setting the
field and record separators for unaligned output to a zero byte, for
easier interfacing with other shell tools.

reviewed by Abhijit Menon-Sen
2012-02-09 20:20:15 +02:00
Bruce Momjian e126958c2e Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
Peter Eisentraut 95d2af1646 Add psql expanded auto mode
This adds the "auto" option to the \x command, which switches to the
expanded mode when the normal output would be wider than the screen.

reviewed by Noah Misch
2011-11-12 17:03:10 +02:00
Peter Eisentraut 1b81c2fe6e Remove many -Wcast-qual warnings
This addresses only those cases that are easy to fix by adding or
moving a const qualifier or removing an unnecessary cast.  There are
many more complicated cases remaining.
2011-09-11 21:54:32 +03:00
Bruce Momjian 5d950e3b0c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
Robert Haas 5aa446c961 Cleanup various comparisons with the constant "true".
Itagaki Takahiro, with slight modifications.
2010-11-14 21:03:48 -05:00
Magnus Hagander 9f2e211386 Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Bruce Momjian 239d769e7e pgindent run for 9.0, second run 2010-07-06 19:19:02 +00:00
Tom Lane 7fdbb8e353 Suppress signed-vs-unsigned-char warning. 2010-05-09 18:17:47 +00:00
Tom Lane ed437e2b27 Adjust comments about avoiding use of printf's %.*s.
My initial impression that glibc was measuring the precision in characters
(which is what the Linux man page says it does) was incorrect.  It does take
the precision to be in bytes, but it also tries to truncate the string at a
character boundary.  The bottom line remains the same: it will mess up
if the string is not in the encoding it expects, so we need to avoid %.*s
anytime there's a significant risk of that.  Previous code changes are still
good, but adjust the comments to reflect this knowledge.  Per research by
Hernan Gonzalez.
2010-05-09 02:16:00 +00:00
Tom Lane 54cd4f0457 Work around a subtle portability problem in use of printf %s format.
Depending on which spec you read, field widths and precisions in %s may be
counted either in bytes or characters.  Our code was assuming bytes, which
is wrong at least for glibc's implementation, and in any case libc might
have a different idea of the prevailing encoding than we do.  Hence, for
portable results we must avoid using anything more complex than just "%s"
unless the string to be printed is known to be all-ASCII.

This patch fixes the cases I could find, including the psql formatting
failure reported by Hernan Gonzalez.  In HEAD only, I also added comments
to some places where it appears safe to continue using "%.*s".
2010-05-08 16:39:53 +00:00
Heikki Linnakangas 95c833b41f Fix translation of strings in psql \d output (translation in headers worked,
but not in cells).
2010-03-01 21:27:26 +00:00
Heikki Linnakangas 93df658a01 Fix numericlocale psql option when used with a null string and latex and troff
formats; a null string must not be formatted as a numeric. The more exotic
formats latex and troff also incorrectly formatted all strings as numerics
when numericlocale was on.

Backpatch to 8.1 where numericlocale option was added.

This fixes bug #5355 reported by Andy Lester.
2010-03-01 20:55:45 +00:00
Bruce Momjian 65e806cba1 pgindent run for 9.0 2010-02-26 02:01:40 +00:00
Tom Lane 07be293a97 Fix memory leakage introduced into print_aligned_text by 8.4 changes
(failure to free col_lineptrs[] array elements) and exacerbated in the
current devel cycle (failure to free "wrap").  This resulted in moderate
bloat of psql over long script runs.  Noted while testing bug #5302,
although what the reporter was complaining of was backend-side leakage.
2010-01-30 18:59:51 +00:00
Bruce Momjian 0239800893 Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
Tom Lane da29cc8022 Simplify psql's new linestyle behavior to default to linestyle=ascii all
the time, rather than hoping we can tell whether the terminal supports
UTF8 characters.  Per discussion.
2009-11-25 20:26:31 +00:00
Tom Lane 1753337cf5 Improve psql's tabular display of wrapped-around data by inserting markers
in the formerly-always-blank columns just to left and right of the data.
Different marking is used for a line break caused by a newline in the data
than for a straight wraparound.  A newline break is signaled by a "+" in the
right margin column in ASCII mode, or a carriage return arrow in UNICODE mode.
Wraparound is signaled by a dot in the right margin as well as the following
left margin in ASCII mode, or an ellipsis symbol in the same places in UNICODE
mode.  "\pset linestyle old-ascii" is added to make the previous behavior
available if anyone really wants it.

In passing, this commit also cleans up a few regression test files that
had unintended spacing differences from the current actual output.

Roger Leigh, reviewed by Gabrielle Roth and other members of PDXPUG.
2009-11-22 05:20:41 +00:00