summaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
AgeCommit message (Collapse)Author
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-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-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-16psql: Fix memory leakPeter Eisentraut
The command \password username leaked memory.
2012-01-01Update copyright notices for year 2012.Bruce Momjian
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-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-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-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-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.
2011-08-04Teach psql to display comments on languages and casts.Robert Haas
The output of \dL (list languages) is fairly narrow, so we just always display the comment. \dC (list casts) can get fairly wide, so we only display comments if the new \dC+ option is specified. Josh Kupershmidt
2011-07-26Add missing newlines at end of error messagesPeter Eisentraut
2011-07-26Replace printf format %i by %dPeter Eisentraut
They are identical, but the overwhelming majority of the code uses %d, so standardize on that.
2011-07-23Unbreak Windows builds broken by EDITOR_LINENUMBER_ARG change.Andrew Dunstan
2011-07-24Change EDITOR_LINENUMBER_SWITCH to an environment variablePeter Eisentraut
Also change "switch" to "arg" because "switch" is a bit of a sloppy term. So the environment variable is called PSQL_EDITOR_LINENUMBER_ARG. Set "+" as hardcoded default value on Unix (since "vi" is the hardcoded default editor), so many users won't have to configure this at all. Move the documentation around a bit to centralize the editor configuration under environment variables, rather than repeating bits of it under every backslash command that invokes an editor.
2011-07-06Add \ir command to psql.Robert Haas
\ir is short for "include relative"; when used from a script, the supplied pathname will be interpreted relative to the input file, rather than to the current working directory. Gurjeet Singh, reviewed by Josh Kupershmidt, with substantial further cleanup by me.
2011-05-22Message improvementPeter Eisentraut
2011-04-10pgindent run before PG 9.1 beta 1.Bruce Momjian
2011-02-19Set psql client encoding from locale by defaultPeter Eisentraut
Add a new libpq connection option client_encoding (which includes the existing PGCLIENTENCODING environment variable), which besides an encoding name accepts a special value "auto" that tries to determine the encoding from the locale in the client's environment, using the mechanisms that have been in use in initdb. psql sets this new connection option to "auto" when running from a terminal and not overridden by setting PGCLIENTENCODING. original code by Heikki Linnakangas, with subsequent contributions by Jaime Casanova, Peter Eisentraut, Stephen Frost, Ibrar Ahmed
2011-02-12DDL support for collationsPeter Eisentraut
- collowner field - CREATE COLLATION - ALTER COLLATION - DROP COLLATION - COMMENT ON COLLATION - integration with extensions - pg_dump support for the above - dependency management - psql tab completion - psql \dO command
2011-02-08Core support for "extensions", which are packages of SQL objects.Tom Lane
This patch adds the server infrastructure to support extensions. There is still one significant loose end, namely how to make it play nice with pg_upgrade, so I am not yet committing the changes that would make all the contrib modules depend on this feature. In passing, fix a disturbingly large amount of breakage in AlterObjectNamespace() and callers. Dimitri Fontaine, reviewed by Anssi Kääriäinen, Itagaki Takahiro, Tom Lane, and numerous others
2011-01-20Add new psql command \dL to list languages.Robert Haas
Original patch by Fernando Ike, revived by Josh Kuperschmidt, reviewed by Andreas Karlsson, and in earlier versions by Tom Lane and Peter Eisentraut.
2011-01-01Basic foreign table support.Robert Haas
Foreign tables are a core component of SQL/MED. This commit does not provide a working SQL/MED infrastructure, because foreign tables cannot yet be queried. Support for foreign table scans will need to be added in a future patch. However, this patch creates the necessary system catalog structure, syntax support, and support for ancillary operations such as COMMENT and SECURITY LABEL. Shigeru Hanada, heavily revised by Robert Haas
2011-01-01Stamp copyrights for year 2011.Bruce Momjian
2010-11-06Implement an "S" option for psql's \dn command.Tom Lane
\dn without "S" now hides all pg_XXX schemas as well as information_schema. Thus, in a bare database you'll only see "public". ("public" is considered a user schema, not a system schema, mainly because it's droppable.) Per discussion back in late September.
2010-10-26Minor fixups for psql's process_file() function.Robert Haas
- Avoid closing stdin, since we didn't open it. Previously multiple inclusions of stdin would be terminated with a single quit, now a separate quit is needed for each invocation. Previous behavior also accessed stdin after it was fclose()d, which is undefined behavior per ANSI C. - Properly restore pset.inputfile, since the caller expects to be able to free that memory. Marti Raudsepp
2010-09-20Remove cvs keywords from all files.Magnus Hagander
2010-08-25Avoid passing signed chars to <ctype.h> functions ... same oldTom Lane
portability mistake as always. Per buildfarm member pika.
2010-08-14Fix \ef and \sf to not fail on functions with nonnull probin.Tom Lane
Update comment about them in pg_get_functiondef.
2010-08-14Add a \sf (show function) command to psql, for those times when you need toTom Lane
look at a function but don't wish to fire up an editor. Pavel Stehule, reviewed by Jan Urbanski
2010-08-12Extend psql's \e and \ef commands so that a line number can be specified,Tom Lane
and the editor's cursor will be initially placed on that line. In \e the lines are counted with respect to the query buffer, while in \ef they are counted with line 1 = first line of function body. These choices are useful for positioning the cursor on the line of a previously-reported error. To avoid assumptions about what switch the user's editor takes for this purpose, invent a new psql variable EDITOR_LINENUMBER_SWITCH with (at present) no default value. One incompatibility from previous behavior is that "\e 1234" will now take "1234" as a line number not a file name. There are at least two ways to select a numerically-named file if you really want to. Pavel Stehule, reviewed by Jan Urbanski, with further editing by Robert Haas and Tom Lane
2010-08-03Kibitzing on \conninfo patch: adjust the order of field output to matchTom Lane
the parameters of \connect, and fix oversight of not enabling translation of the messages. Also, adjust \connect's similar messages to match, and deal with 8.2-era violation of basic translatability guidelines there.
2010-07-23Have psql avoid describing local sockets as host names.Robert Haas
We now use the phrase 'via local socket in' rather than 'on host' in both \c and \conninfo output, when applicable. Fujii Masao, with some kibitzing by me.
2010-07-20Have \conninfo mention the port even for local sockets.Robert Haas
Per discussion with David Christensen, there can be multiple instances of PG accessible via local sockets, and you need the port to see which one you're actually connected to. David's original patch worked this way, but I inadvertently ripped it out during commit.
2010-07-20Add \conninfo command to psql, to show current connection info.Robert Haas
David Christensen. Reviewed by Steve Singer. Some further changes by me.
2010-07-06pgindent run for 9.0, second runBruce Momjian
2010-05-21Unbreak \h; can't do strlen(NULL).Robert Haas
This was broken by the following commmit. Although the original commit was backpatched all the way to 7.4, this particular bug exists only in the version applied to HEAD. http://archives.postgresql.org/pgsql-committers/2010-05/msg00058.php
2010-05-08Work around a subtle portability problem in use of printf %s format.Tom Lane
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-04-03\ddp should be recognized as such even if user appends S or + to it.Tom Lane
Those options do nothing right now, but might be wanted later, and in any case it's confusing for the command to be interpreted as \dd if anything is appended. Per Jaime Casanova.
2010-03-08Return proper exit code (3) from psql when ON_ERROR_STOP=on andBruce Momjian
--single-transaction are both used and the failure happens in commit, e.g. failed deferred trigger. Also properly free BEGIN/COMMIT result structures from --single-transaction. Per report from Dominic Bevacqua
2010-02-26pgindent run for 9.0Bruce Momjian
2010-02-16Prevent psql version banner from being printed by the \c command if theBruce Momjian
versions match, per report from Peter.
2010-02-05Modify recently added PQconnectdbParams() with new argument, expand_dbname.Joe Conway
If expand_dbname is non-zero and dbname contains an = sign, it is taken as a conninfo string in exactly the same way as if it had been passed to PQconnectdb. This is equivalent to the way PQsetdbLogin() works, allowing PQconnectdbParams() to be a complete alternative. Also improve the way the new function is called from psql and replace a previously missed call to PQsetdbLogin() in psql. Additionally use PQconnectdbParams() for pg_dump and friends, and the bin/scripts command line utilities such as vacuumdb, createdb, etc. Finally, update the documentation for the new parameter, as well as the nuances of precedence in cases where key words are repeated or duplicated in the conninfo string.
2010-01-02Update copyright for the year 2010.Bruce Momjian
2009-12-01psql -f -Bruce Momjian
Adjust psql -f - to behave like a normal file and honor the -1 flag. Report from Robert Haas
2009-11-22Improve psql's tabular display of wrapped-around data by inserting markersTom Lane
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-10-13Add "\pset linestyle ascii/unicode" option to psql, allowing our traditionalTom Lane
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-07Make it possibly to specify GUC params per user and per database.Alvaro Herrera
Create a new catalog pg_db_role_setting where they are now stored, and better encapsulate the code that deals with settings into its realm. The old datconfig and rolconfig columns are removed. psql has gained a \drds command to display the settings. Backwards compatibility warning: while the backwards-compatible system views still have the config columns, they no longer completely represent the configuration for a user or database. Catalog version bumped.