summaryrefslogtreecommitdiff
path: root/src/bin/psql
AgeCommit message (Collapse)Author
2012-03-08psql: Remove useless codePeter Eisentraut
Apparently a copy-and-paste mistake introduced in 8ddd22f2456af0155f9c183894f481203e86b76e. found by Coverity
2012-03-07Fix indentation of \d footers for non-ASCII cases.Tom Lane
Multi-line "Inherits:" and "Child tables:" footers were misindented when those strings' translations involved multibyte characters, because we were using strlen() instead of an appropriate display width measurement. In passing, avoid doing gettext() more than once per loop in these places. While at it, fix pg_wcswidth(), which has been entirely broken since about 8.2, but fortunately has been unused for the same length of time. Report and patch by Sergey Burladyan (bug #6480)
2012-03-07psql: Avoid some spurious output if the server croaks.Robert Haas
Fixes a regression in commit 08146775acd8bfe0fcc509c71857abb928697171. Noah Misch
2012-03-07psql: Fix memory leakPeter Eisentraut
In expanded auto mode, a lot of allocated memory was not cleaned up. found by Coverity
2012-03-07psql: Fix invalid memory accessPeter Eisentraut
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-03Provide environment overrides for psql file locations.Andrew Dunstan
PSQL_HISTORY provides an alternative for the command history file, and PSQLRC provides an alternative location for the .psqlrc file.
2012-03-01psql: Improve error display for psql -f -Peter Eisentraut
Running "psql -f -" used to print psql:<stdin>:1: ERROR: blah but that got broken between 8.4 and 9.0 (commit b291c0fba83a1e93868e2f69c03be195d620f30c), and now it printed psql:-:1: ERROR: blah This reverts to the old behavior and cleans up some code that was left dead or useless by the mentioned commit.
2012-02-28Add const qualifiers where they are accidentally cast awayPeter Eisentraut
This only produces warnings under -Wcast-qual, but it's more correct and consistent in any case.
2012-02-28psql: when tab-completing, use quotes on file names that need themAlvaro Herrera
psql backslash commands that deal with file or directory names require quotes around those that have spaces, single quotes, or backslashes. However, tab-completing such names does not provide said quotes, and is thus almost useless with them. This patch fixes the problem by having a wrapper function around rl_filename_completion_function that dequotes on input and quotes on output. This eases dealing with such names. Author: Noah Misch
2012-02-09psql: Support zero byte field and record separatorsPeter Eisentraut
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-01psql: Case preserving completion of SQL key wordsPeter Eisentraut
Instead of always completing SQL key words in upper case, look at the word being completed and match the case. reviewed by Fujii Masao
2012-01-31psql: Reduce the amount of const lies a bitPeter Eisentraut
2012-01-25Have \copy go through SendQueryAlvaro Herrera
This enables a bunch of features, notably ON_ERROR_ROLLBACK. It also makes COPY failure (either in the server or psql) as a whole behave more sanely in psql. Additionally, having more commands in the same command line as COPY works better (though since psql splits lines at semicolons, this doesn't matter much unless you're using -c). Also tighten a couple of switches on PQresultStatus() to add PGRES_COPY_BOTH support and stop assuming that unknown statuses received are errors; have those print diagnostics where warranted. Author: Noah Misch
2012-01-21psql: Add support for tab completion of GRANT/REVOKE rolePeter Eisentraut
Previously, only GRANT/REVOKE privilege was supported. reviewed by Pavel Stehule
2012-01-18Show psql timing output for failed queries as well as successful onesMagnus Hagander
This is useful for example when a long-runing statement such as CREATE INDEX fails after a long time.
2012-01-16psql: Fix memory leakPeter Eisentraut
The command \password username leaked memory.
2012-01-01Update copyright notices for year 2012.Bruce Momjian
2011-12-27Standardize treatment of strcmp() return valuePeter Eisentraut
Always compare the return value to 0, don't use cute tricks like if (!strcmp(...)).
2011-12-27Remove support for on_exit()Peter Eisentraut
All supported platforms support the C89 standard function atexit() (SunOS 4 probably being the last one not to), and supporting both makes the code clumsy.
2011-12-20Add support for privileges on typesPeter Eisentraut
This adds support for the more or less SQL-conforming USAGE privilege on types and domains. The intent is to be able restrict which users can create dependencies on types, which restricts the way in which owners can alter types. reviewed by Yeb Havinga
2011-12-19Allow CHECK constraints to be declared ONLYAlvaro Herrera
This makes them enforceable only on the parent table, not on children tables. This is useful in various situations, per discussion involving people bitten by the restrictive behavior introduced in 8.4. Message-Id: 8762mp93iw.fsf@comcast.net CAFaPBrSMMpubkGf4zcRL_YL-AERUbYF_-ZNNYfb3CVwwEqc9TQ@mail.gmail.com Authors: Nikhil Sontakke, Alex Hunsaker Reviewed by Robert Haas and myself
2011-12-07Remove spclocation field from pg_tablespaceMagnus Hagander
Instead, add a function pg_tablespace_location(oid) used to return the same information, and do this by reading the symbolic link. Doing it this way makes it possible to relocate a tablespace when the database is down by simply changing the symbolic link.
2011-12-04Add a \setenv command to psql.Andrew Dunstan
This can be used to set (or unset) environment variables that will affect programs called by psql (such as the PAGER), probably most usefully in a .psqlrc file. Andrew Dunstan, reviewed by Josh Kupershmidt.
2011-12-02psql: Make temporary editor files have .sql extensionPeter Eisentraut
This gives editors a better chance to treat these files as the SQL files that they are.
2011-11-15Don't elide blank lines when accumulating psql command history.Robert Haas
This can change the meaning of queries, if the blank line happens to occur in the middle of a quoted literal, as per complaint from Tomas Vondra. Back-patch to all supported branches.
2011-11-12Add psql expanded auto modePeter Eisentraut
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-11Fix psql's \dd version check for operator families.Robert Haas
Report and patch by Josh Kupershmidt; comment revisions by me.
2011-11-10Throw nice error if server is too old to support psql's \ef or \sf command.Tom Lane
Previously, you'd get "function pg_catalog.pg_get_functiondef(integer) does not exist", which is at best rather unprofessional-looking. Back-patch to 8.4 where \ef was introduced. Josh Kupershmidt
2011-11-05Show statistics target for columns in \d+ on a tableMagnus Hagander
2011-11-05Make psql \d on a sequence show the table/column owning itMagnus Hagander
2011-11-04Add missing space in commentMagnus Hagander
2011-10-24Make TABLE tab complation in psql include all relationsMagnus Hagander
Not just tables, since views also work fine with the TABLE command.
2011-10-23Make psql support tab completion of EXECUTE <prepared-statement-name>.Tom Lane
Andreas Karlsson, reviewed by Josh Kupershmidt
2011-10-20Rewrite tab completion's previous-word fetching for more sanity.Tom Lane
Make it return empty strings when there are no more words to the left of the current position, instead of sometimes returning NULL and other times returning copies of the leftmost word. Also, fetch the words in one scan, rather than the previous wasteful approach of starting from scratch for each word. Make the code a bit harder to break when someone decides we need more words of context, too. (There was actually a memory leak here, because whoever added prev6_wd neglected to free it.)
2011-10-18Suppress remaining -Waddress warnings from recent gcc versions.Tom Lane
Still an exercise in satisfying pedants.
2011-10-18Suppress -Wunused-result warnings about write() and fwrite().Tom Lane
This is merely an exercise in satisfying pedants, not a bug fix, because in every case we were checking for failure later with ferror(), or else there was nothing useful to be done about a failure anyway. Document the latter cases.
2011-10-14Allow a major PG version psql .psqlrc file to be used if a minorBruce Momjian
matching version file does not exist. This avoids needing to rename .psqlrc files after minor version upgrades.
2011-09-11Remove many -Wcast-qual warningsPeter Eisentraut
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-01Remove unnecessary #include references, per pgrminclude script.Bruce Momjian
2011-08-26Clean up weird corner cases in lexing of psql meta-command arguments.Tom Lane
These changes allow backtick command evaluation and psql variable interpolation to happen on substrings of a single meta-command argument. Formerly, no such evaluations happened at all if the backtick or colon wasn't the first character of the argument, and we considered an argument completed as soon as we'd processed one backtick, variable reference, or quoted substring. A string like 'FOO'BAR was thus taken as two arguments not one, not exactly what one would expect. In the new coding, an argument is considered terminated only by unquoted whitespace or backslash. Also, clean up a bunch of omissions, infelicities and outright errors in the psql documentation of variables and metacommand argument syntax.
2011-08-26Support non-ASCII letters in psql variable names.Tom Lane
As in the backend, the implementation actually accepts any non-ASCII character, but we only document that you can use letters.
2011-08-25Add makefile rules to check for backtracking in backend and psql lexers.Tom Lane
Per discussion, we should enforce the policy of "no backtracking" in these performance-sensitive scanners.
2011-08-25Fix psql lexer to avoid use of backtracking.Tom Lane
Per previous experimentation, backtracking slows down lexing performance significantly (by about a third). It's usually pretty easy to avoid, just need to have rules that accept an incomplete construct and do whatever the lexer would have done otherwise. The backtracking was introduced by the patch that added quoted variable substitution. Back-patch to 9.0 where that was added.
2011-08-25Add "%option warn" to all flex input files that lacked it.Tom Lane
This is recommended in the flex manual, and there seems no good reason not to use it everywhere.
2011-08-25Change format of SQL/MED generic options in psql backslash commands.Robert Haas
Rather than dumping out the raw array as PostgreSQL represents it internally, we now print it out in a format similar to the one in which the user input it, which seems a lot more user friendly. Shigeru Hanada
2011-08-17Translation updatesPeter Eisentraut
2011-08-11Display both per-table and per-column FDW options in psql's \d output.Robert Haas
Along the way, rename "Options" to "FDW Options" in various places for consistency and clarity. Shigeru Hanada
2011-08-11Change psql's \dd command to do something more useful.Robert Haas
Instead of displaying comments on an arbitrary subset of the object types which support them, make \dd display comments on exactly those object types which don't have their own backlash commands. We now regard the display of comments as properly the job of the relevant backslash command (though many of them do so only in verbose mode) rather than something that \dd should be responsible for. However, a handful of object types have no backlash command, so make \dd give information about those. Josh Kupershmidt
2011-08-08Teach psql to display the comments on SQL/MED objects in verbose mode.Robert Haas
The relevant backslash commands already exist, so we're just adding an additional column. With this commit, all objects that have psql backslash commands and accept comments should now display those comments at least in verbose mode. Josh Kupershmidt, with doc additions by me.
2011-08-08Teach psql to display the comments on conversions and domains.Robert Haas
\dc and \dD now accept a "+" option, which will cause the comments to be displayed. Along the way, correct a few oversights in the previous commit in this area, 3b17efdfdd846c9bfad1637686e6f18198ea3df5 - namely, (1) when \dL+ is used, make description still be the last column, for consistency with what we've done elsewhere; and (2) document the difference between \dC and \dC+. Josh Kupershmidt, with a couple of doc changes by me.