Commit Graph

141 Commits

Author SHA1 Message Date
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
Tom Lane 42ec8ad628 Add "\pset linestyle ascii/unicode" option to psql, allowing our traditional
ASCII-art style of table output to be upgraded to use Unicode box drawing
characters if desired.  By default, psql will use the Unicode characters
whenever client_encoding is UTF8.

The patch forces linestyle=ascii in pg_regress usage, ensuring we don't
break the regression tests in Unicode locales.

Roger Leigh
2009-10-13 21:04:01 +00:00
Tom Lane bfd06a713b Fix several places where a function was declared static and then defined
without static.  Per testing with a compiler that complains about this.
2009-06-12 16:17:29 +00:00
Bruce Momjian d747140279 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
2009-06-11 14:49:15 +00:00
Tom Lane 0d5478196a Trivial code style cleanup around a couple of ngettext calls. 2009-06-04 19:17:39 +00:00
Peter Eisentraut 84f2f5c023 Fix to use the same format specifiers in both branches of a ngettext().
Zdenek Kotala
2009-05-27 20:47:55 +00:00
Peter Eisentraut fbaeae3fc5 Message fix
(I guess this was a cruise replace mistake.)
2009-04-11 14:11:45 +00:00
Peter Eisentraut 8032d76b5b Gettext plural support
In the backend, I changed only a handful of exemplary or important-looking
instances to make use of the plural support; there is probably more work
there.  For the rest of the source, this should cover all relevant cases.
2009-03-26 22:26:08 +00:00
Bruce Momjian 511db38ace Update copyright for 2009. 2009-01-01 17:24:05 +00:00
Bruce Momjian c9b2591efc In psql, rename trans_* variables to translate_*, for clarity. 2008-07-14 22:00:04 +00:00
Magnus Hagander 06e6573d57 Fix function headers not matching prototype in header file, per
compiler warnings on msvc.
2008-05-21 16:00:10 +00:00
Andrew Dunstan 07d08a8828 Remove old kluge put in to allow Windows regression tests to succeed, and now
found to have been made necessary by our skipping tty detection on Windows. Now
that we are doing tty detection on Windows the kluge is unnecessary and wrong.
2008-05-18 06:50:08 +00:00
Bruce Momjian 265f19d78b Use isatty() test for pager on Win32; not sure why it was disabled for
that platform.
2008-05-17 23:34:44 +00:00
Bruce Momjian e2cd62c3e1 In psql, test for output to stdout when forcing pager for wide output. 2008-05-17 21:40:44 +00:00
Tom Lane 2e27b0e146 Fix utterly-bogus code for computing row heights. Per crashes on
spoonbill, though one wonders why it didn't misbehave everywhere.
In passing remove some unnecessary modulo calculations.
2008-05-17 17:52:14 +00:00
Tom Lane e7b498bd5e Recent patch doesn't compile without <limits.h> 2008-05-16 18:35:38 +00:00
Bruce Momjian 43ee22826b Add detection of psql pager to trigger on wide output. Also add pager
detection for wrapped lines or lines with newlines that need pager to
display.
2008-05-16 16:59:05 +00:00
Alvaro Herrera e6a64bd3b6 Fix a bug in the previous patch, which caused the title pointer to be used
before it was actually set.
2008-05-13 00:14:11 +00:00
Alvaro Herrera 1e9199e84c Improve psql's internal print.c code by introducing an actual print API.
Provides for better code readability, but mainly this is infrastructure changes
to allow further changes such as arbitrary footers on printed tables.  Also,
the translation status of each element in the table is more easily customized.

Brendan Jurd, with some editorialization by me.
2008-05-12 22:59:58 +00:00
Tom Lane 125ed6853e Restore psql's former behavior that padding spaces to the right of the last
output column are not emitted.  (That change already caused more noise in
the regression test output files than I would like.)  Provide some needed
editorial help for comments, clean up code formatting.
2008-05-10 03:31:58 +00:00
Bruce Momjian 5adf98ae24 Add psql '\pset format wrapped' mode to wrap output to screen width, or
file/pipe output too if \pset columns' is set.

Bryce Nesbitt
2008-05-08 17:04:26 +00:00
Tom Lane 039dfbfd5d Reduce the need for frontend programs to include "postgres.h" by refactoring
inclusions in src/include/catalog/*.h files.  The main idea here is to push
function declarations for src/backend/catalog/*.c files into separate headers,
rather than sticking them into the corresponding catalog definition file as
has been done in the past.  This commit only carries out that idea fully for
pg_proc, pg_type and pg_conversion, but that's enough for the moment ---
if pg_list.h ever becomes unsafe for frontend code to include, we'll need
to work a bit more.

Zdenek Kotala
2008-03-27 03:57:34 +00:00
Bruce Momjian 9098ab9e32 Update copyrights in source tree to 2008. 2008-01-01 19:46:01 +00:00
Tom Lane df4271fedd Improve the method of localizing column names and other fixed strings in
psql's \d commands and other uses of printQuery().  Previously we would pass
these strings through gettext() and then send them to the server as literals
in the SQL query.  But the code was not set up to handle doubling of quotes in
the strings, causing failure if a translation attempted to use the wrong kind
of quote marks, as indeed is now the case for (at least) the French
translation of \dFp.  Another hazard was that gettext() would translate to
whatever encoding was implied by the client's LC_CTYPE setting, which might be
different from the client_encoding setting, which would probably cause the
server to reject the query as mis-encoded.  The new arrangement is to send the
untranslated ASCII strings to the server, and do the translations inside
printQuery() after the query results come back.  Per report from Guillaume
Lelarge and subsequent discussion.
2007-12-12 21:41:47 +00:00
Bruce Momjian b85cf684f7 Add more comments about thousands separator handling. 2007-11-22 17:51:39 +00:00
Bruce Momjian d9bc7a3946 Add comments about thousands separator logic. 2007-11-22 15:10:05 +00:00
Bruce Momjian 3894e7cc55 When setting default thousands separator when locale has "", use logic
so new thousands separator doesn't match decimal symbol.
2007-11-21 22:28:18 +00:00