aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql
Commit message (Collapse)AuthorAge
* Get rid of obsolete parse_version helper function.Heikki Linnakangas2013-03-26
| | | | | | | For getting the server's version in numeric form, use PQserverVersion(). It does the exact same parsing as dumputils.c's parse_version(), and has been around in libpq for a long time. For the client's version, just use the PG_VERSION_NUM constant.
* Move pqsignal() to libpgport.Tom Lane2013-03-17
| | | | | | | | | 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.
* Also update psqlscan.l with the UESCAPE error rule changes.Heikki Linnakangas2013-03-14
| | | | | | | | | Even though this patch had no user-visible difference, better keep the code in psqlscan.l sync with the backend lexer. And of course it's nice to shrink the psql binary, too. Ecpg's version of the lexer doesn't have the error rule, it doesn't try to avoid backing up, so it doesn't need to be modified. As reminded by Tom Lane
* Add fe_memutils.c to nls.mk where usedPeter Eisentraut2013-03-06
|
* Adjust nls.mk for split out of wait_error.cPeter Eisentraut2013-03-06
|
* psql: Let \l accept a patternPeter Eisentraut2013-03-04
| | | | reviewed by Satoshi Nagayasu
* Add a materialized view relations.Kevin Grittner2013-03-03
| | | | | | | | | | | | | | | | | | | | | | A materialized view has a rule just like a view and a heap and other physical properties like a table. The rule is only used to populate the table, references in queries refer to the materialized data. This is a minimal implementation, but should still be useful in many cases. Currently data is only populated "on demand" by the CREATE MATERIALIZED VIEW and REFRESH MATERIALIZED VIEW statements. It is expected that future releases will add incremental updates with various timings, and that a more refined concept of defining what is "fresh" data will be developed. At some point it may even be possible to have queries use a materialized in place of references to underlying tables, but that requires the other above-mentioned features to be working first. Much of the documentation work by Robert Haas. Review by Noah Misch, Thom Brown, Robert Haas, Marko Tiikkaja Security review by KaiGai Kohei, with a decision on how best to implement sepgsql still pending.
* Add support for piping COPY to/from an external program.Heikki Linnakangas2013-02-27
| | | | | | | | | | | | | | | | | | This includes backend "COPY TO/FROM PROGRAM '...'" syntax, and corresponding psql \copy syntax. Like with reading/writing files, the backend version is superuser-only, and in the psql version, the program is run in the client. In the passing, the psql \copy STDIN/STDOUT syntax is subtly changed: if you the stdin/stdout is quoted, it's now interpreted as a filename. For example, "\copy foo from 'stdin'" now reads from a file called 'stdin', not from standard input. Before this, there was no way to specify a filename called stdin, stdout, pstdin or pstdout. This creates a new function in pgport, wait_result_to_str(), which can be used to convert the exit status of a process, as returned by wait(3), to a human-readable string. Etsuro Fujita, reviewed by Amit Kapila.
* Create libpgcommon, and move pg_malloc et al to itAlvaro Herrera2013-02-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | libpgcommon is a new static library to allow sharing code among the various frontend programs and backend; this lets us eliminate duplicate implementations of common routines. We avoid libpgport, because that's intended as a place for porting issues; per discussion, it seems better to keep them separate. The first use case, and the only implemented by this patch, is pg_malloc and friends, which many frontend programs were already using. At the same time, we can use this to provide palloc emulation functions for the frontend; this way, some palloc-using files in the backend can also be used by the frontend cleanly. To do this, we change palloc() in the backend to be a function instead of a macro on top of MemoryContextAlloc(). This was previously believed to cause loss of performance, but this implementation has been tweaked by Tom and Andres so that on modern compilers it provides a slight improvement over the previous one. This lets us clean up some places that were already with localized hacks. Most of the pg_malloc/palloc changes in this patch were authored by Andres Freund. Zoltán Böszörményi also independently provided a form of that. libpgcommon infrastructure was authored by Álvaro.
* psql: Improve unaligned expanded output for zero rowsPeter Eisentraut2013-02-09
| | | | This used to erroneously print an empty line. Now it prints nothing.
* psql: Improve expanded print output in tuples-only modePeter Eisentraut2013-02-09
| | | | | | 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.
* Add support for ALTER RULE ... RENAME TO.Tom Lane2013-02-08
| | | | Ali Dar, reviewed by Dean Rasheed.
* Create a psql command \gset to store query results into psql variables.Tom Lane2013-02-02
| | | | | | This eases manipulation of query results in psql scripts. Pavel Stehule, reviewed by Piyush Newe, Shigeru Hanada, and Tom Lane
* Prevent "\g filename" from affecting subsequent commands after an error.Tom Lane2013-02-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the previous coding, psql's state variable saying that output should go to a file was only reset after successful completion of a query returning tuples. Thus for example, regression=# select 1/0 regression-# \g somefile ERROR: division by zero regression=# select 1/2; regression=# ... huh, I wonder where that output went. Even more oddly, the state was not reset even if it's the file that's causing the failure: regression=# select 1/2 \g /foo /foo: Permission denied regression=# select 1/2; /foo: Permission denied regression=# select 1/2; /foo: Permission denied This seems to me not to satisfy the principle of least surprise. \g is certainly not documented in a way that suggests its effects are at all persistent. To fix, adjust the code so that the flag is reset at exit from SendQuery no matter what happened. Noted while reviewing the \gset patch, which had comparable issues. Arguably this is a bug fix, but I'll refrain from back-patching for now.
* Add prosecdef to \df+ output.Heikki Linnakangas2013-01-25
| | | | Jon Erdman, reviewed by Phil Sorber and Stephen Frost.
* Use correct output device for Windows prompts.Andrew Dunstan2013-01-24
| | | | | | | | | | This ensures that mapping of non-ascii prompts to the correct code page occurs. Bug report and original patch from Alexander Law, reviewed and reworked by Noah Misch. Backpatch to all live branches.
* Rename new latex longtable function name, for consistencyBruce Momjian2013-01-18
|
* psql latex fixesBruce Momjian2013-01-18
| | | | | | 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'.
* Add a latex-longtable output format to psqlBruce Momjian2013-01-17
| | | | | latex longtable is more powerful than the 'tabular' output format 'latex' uses. Also add border=3 support to 'latex'.
* Make \? help message more clear when not connected.Heikki Linnakangas2013-01-15
| | | | | | | On second thought, "none" could mislead to think that you're connected a database with that name. Duplicate the whole string, so that it can be more easily translated. In back-branches, thought, just use an empty string in place of the database name, to avoid adding a translatable string.
* Don't pass NULL to fprintf, if not currently connected to a database.Heikki Linnakangas2013-01-15
| | | | | Backpatch all the way to 8.3. Fixes bug #7811, per report and diagnosis by Meng Qingzhong.
* Update copyrights for 2013Bruce Momjian2013-01-01
| | | | | Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
* Provide Assert() for frontend code.Andrew Dunstan2012-12-14
| | | | | | Per discussion on-hackers. psql is converted to use the new code. Follows a suggestion from Heikki Linnakangas.
* Fix assorted bugs in privileges-for-types patch.Tom Lane2012-12-09
| | | | | | | | Commit 729205571e81b4767efc42ad7beb53663e08d1ff added privileges on data types, but there were a number of oversights. The implementation of default privileges for types missed a few places, and pg_dump was utterly innocent of the whole concept. Per bug #7741 from Nathan Alden, and subsequent wider investigation.
* Fix psql crash while parsing SQL file whose encoding is different fromTatsuo Ishii2012-12-02
| | | | | | client encoding and the client encoding is not *safe* one. Such an example is, file encoding is UTF-8 and client encoding SJIS. Patch contributed by Jiang Guiqing.
* In our source code, make a copy of getopt's 'optarg' string arguments,Bruce Momjian2012-10-12
| | | | rather than just storing a pointer.
* Refactor flex and bison make rulesPeter Eisentraut2012-10-11
| | | | | | | | Numerous flex and bison make rules have appeared in the source tree over time, and they are all virtually identical, so we can replace them by pattern rules with some variables for customization. Users of pgxs will also be able to benefit from this.
* Work around unportable behavior of malloc(0) and realloc(NULL, 0).Tom Lane2012-10-02
| | | | | | | | | | | | | | | | On some platforms these functions return NULL, rather than the more common practice of returning a pointer to a zero-sized block of memory. Hack our various wrapper functions to hide the difference by substituting a size request of 1. This is probably not so important for the callers, who should never touch the block anyway if they asked for size 0 --- but it's important for the wrapper functions themselves, which mistakenly treated the NULL result as an out-of-memory failure. This broke at least pg_dump for the case of no user-defined aggregates, as per report from Matthew Carrington. Back-patch to 9.2 to fix the pg_dump issue. Given the lack of previous complaints, it seems likely that there is no live bug in previous releases, even though some of these functions were in place before that.
* Standardize naming of malloc/realloc/strdup wrapper functions.Tom Lane2012-10-02
| | | | | | | | | | | | 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.)
* psql: Mark table headers in \drds output for translationPeter Eisentraut2012-09-29
|
* psql: Add more constraint completionPeter Eisentraut2012-09-14
| | | | | | | - ALTER DOMAIN ... DROP/RENAME/VALIDATE CONSTRAINT - ALTER TABLE ... RENAME/VALIDATE CONSTRAINT - COMMENT ON CONSTRAINT - SET CONSTRAINTS
* Make psql's \d+ show reloptions for all relkinds.Tom Lane2012-09-03
| | | | | | | | | | | | Formerly it would only show them for relkinds 'r' and 'f' (plain tables and foreign tables). However, as of 9.2, views can also have reloptions, namely security_barrier. The relkind restriction seems pointless and not at all future-proof, so just print reloptions whenever there are any. In passing, make some cosmetic improvements to the code that pulls the "tableinfo" fields out of the PGresult. Noted and patched by Dean Rasheed, with adjustment for all relkinds by me.
* psql: Reduce compatibility warningPeter Eisentraut2012-08-31
| | | | | | Only warn when connecting to a newer server, since connecting to older servers works pretty well nowadays. Also update the documentation a little about current psql/server compatibility expectations.
* Prevent psql tab completion in SET from adding TO when the equals signBruce Momjian2012-08-28
| | | | | | has no space before it. Report by Erik Rijkers
* Use psql_error() for most psql error calls, per request from Magnus.Bruce Momjian2012-08-25
|
* Improved tab completion for CLUSTER VERBOSE.Robert Haas2012-08-20
| | | | Jeff Janes
* Tab complete "TABLE whatever DROP CONSTRAINT" with a constraint name.Robert Haas2012-08-20
| | | | Jeff Janes
* Add C comment about new \c parameter requirement for crashed connections.Bruce Momjian2012-08-15
|
* In psql, if the is no connection object, e.g. due to a server crash,Bruce Momjian2012-08-15
| | | | | require all parameters for \c, rather than using the defaults, which might be wrong.
* Make psql -1 < file behave as expected.Robert Haas2012-08-09
| | | | | | | | | | Previously, the -1 option was silently ignored. Also, emit an error if -1 is used in a context where it won't be respected, to avoid user confusion. Original patch by Fabien COELHO, but this version is quite different from the original submission.
* Tab complete table names after ALTER TABLE x [NO] INHERIT.Robert Haas2012-07-26
| | | | Jeff Janes
* Syntax support and documentation for event triggers.Robert Haas2012-07-18
| | | | | | | | | | | | | | They don't actually do anything yet; that will get fixed in a follow-on commit. But this gets the basic infrastructure in place, including CREATE/ALTER/DROP EVENT TRIGGER; support for COMMENT, SECURITY LABEL, and ALTER EXTENSION .. ADD/DROP EVENT TRIGGER; pg_dump and psql support; and documentation for the anticipated initial feature set. Dimitri Fontaine, with review and a bunch of additional hacking by me. Thom Brown extensively reviewed earlier versions of this patch set, but there's not a whole lot of that code left in this commit, as it turns out.
* Remove unreachable codePeter Eisentraut2012-07-16
| | | | | | | The Solaris Studio compiler warns about these instances, unlike more mainstream compilers such as gcc. But manual inspection showed that the code is clearly not reachable, and we hope no worthy compiler will complain about removing this code.
* Run updated copyright.pl on HEAD and 9.2 trees, updating the psqlBruce Momjian2012-07-06
| | | | | | \copyright output to 2012. Backpatch to 9.2.
* Don't try to trim "../" in join_path_components().Tom Lane2012-07-05
| | | | | | | | | | | | | | | | | | join_path_components() tried to remove leading ".." components from its tail argument, but it was not nearly bright enough to do so correctly unless the head argument was (a) absolute and (b) canonicalized. Rather than try to fix that logic, let's just get rid of it: there is no correctness reason to remove "..", and cosmetic concerns can be taken care of by a subsequent canonicalize_path() call. Per bug #6715 from Greg Davidson. Back-patch to all supported branches. It appears that pre-9.2, this function is only used with absolute paths as head arguments, which is why we'd not noticed the breakage before. However, third-party code might be expecting this function to work in more general cases, so it seems wise to back-patch. In HEAD and 9.2, also make some minor cosmetic improvements to callers.
* Fix function argument tab completion for schema-qualified or quoted function ↵Magnus Hagander2012-07-05
| | | | | | names Dean Rasheed, reviewed by Josh Kupershmidt
* Run newly-configured perltidy script on Perl files.Bruce Momjian2012-07-04
| | | | Run on HEAD and 9.2.
* Assorted message style improvementsPeter Eisentraut2012-07-02
|
* Make documentation of --help and --version options more consistentPeter Eisentraut2012-06-18
| | | | | | Before, some places didn't document the short options (-? and -V), some documented both, some documented nothing, and they were listed in various orders. Now this is hopefully more consistent and complete.
* Make \conninfo print SSL information.Robert Haas2012-06-14
| | | | Alastair Turner, per suggestion from Bruce Momjian.