Commit Graph

2342 Commits

Author SHA1 Message Date
Bruce Momjian c3a69c3b3b Attached is a patch that enhances the "\h" capability in psql. I often
find myself typing a command and then wanting to get the syntax for it.
So I do a ctrl-a and add a \h: but psql does not recognize the command,
because I have stuff attached to it (e.g. "alter table foobar"), so I
have to scroll over and delete everything except the name of the command
itself. This patch gives \h three chances to match: if nothing matches
the complete string (current behavior), it tries to match the first two
words (e.g. "ALTER TABLE"). If that fails, it tries to match the first
word (e.g. "DELETE").

Greg Sabino Mullane
2005-07-06 03:14:48 +00:00
Tom Lane eb5949d190 Arrange for the postmaster (and standalone backends, initdb, etc) to
chdir into PGDATA and subsequently use relative paths instead of absolute
paths to access all files under PGDATA.  This seems to give a small
performance improvement, and it should make the system more robust
against naive DBAs doing things like moving a database directory that
has a live postmaster in it.  Per recent discussion.
2005-07-04 04:51:52 +00:00
Bruce Momjian 74b49a8129 Add E'' to internally created SQL strings that contain backslashes.
Improve code clarity by using macros for E'' processing.
2005-07-02 17:01:59 +00:00
Bruce Momjian 539bc9fc91 Add code to pg_dump to use E'' strings when backslashes are used in dump
files.
2005-07-01 21:03:25 +00:00
Bruce Momjian 2f7d369a5c Clarify code to double \\ and '. 2005-07-01 17:40:29 +00:00
Tom Lane 51c58812d9 Dump comments for large objects. 2005-06-30 03:03:04 +00:00
Tom Lane 365205dd2a Fix broken initdb -W option, per Michael Fuhr. 2005-06-28 15:38:12 +00:00
Tom Lane 7762619e95 Replace pg_shadow and pg_group by new role-capable catalogs pg_authid
and pg_auth_members.  There are still many loose ends to finish in this
patch (no documentation, no regression tests, no pg_dump support for
instance).  But I'm going to commit it now anyway so that Alvaro can
make some progress on shared dependencies.  The catalog changes should
be pretty much done.
2005-06-28 05:09:14 +00:00
Tom Lane c3be085ab7 Modify pg_dump to assume that a check constraint is inherited if its
name matches the name of any parent-table constraint, without looking
at the constraint text.  This is a not-very-bulletproof workaround for
the problem exhibited by Berend Tober last month.  We really ought to
record constraint inheritance status in pg_constraint, but it's looking
like that may not get done for 8.1 --- and even if it does, we will
need this kluge for dumping from older servers.
2005-06-27 02:17:47 +00:00
Tom Lane d395aecffa Code review for escape-strings patch. Sync psql and plpgsql lexers
with main, avoid using a SQL-defined SQLSTATE for what is most definitely
not a SQL-compatible error condition, fix documentation omissions,
adhere to message style guidelines, don't use two GUC_REPORT variables
when one is sufficient.  Nothing done about pg_dump issues.
2005-06-26 19:16:07 +00:00
Bruce Momjian bb3cce4ec9 Add E'' syntax so eventually normal strings can treat backslashes
literally.

Add GUC variables:

        "escape_string_warning" - warn about backslashes in non-E strings
        "escape_string_syntax" - supports E'' syntax?
        "standard_compliant_strings" - treats backslashes literally in ''

Update code to use E'' when escapes are used.
2005-06-26 03:04:37 +00:00
Tom Lane 4cc7a93d22 Make REINDEX DATABASE do what one would expect, namely reindex all indexes
in the database.  The old behavior (reindex system catalogs only) is now
available as REINDEX SYSTEM.  I did not add the complementary REINDEX USER
case since there did not seem to be consensus for this, but it would be
trivial to add later.  Per recent discussions.
2005-06-22 21:14:31 +00:00
Tom Lane 84d73a6dbc Add a validator function for plperl. Andrew Dunstan 2005-06-22 16:45:51 +00:00
Neil Conway 05db8b501b Correct some code in pg_restore when reading the header of a tar archive:
(1) The code doesn't initialize `sum', so the initial "does the checksum
    match?" test is wrong.

(2) The loop that is intended to check for a "null block" just checks
    the first byte of the tar block 512 times, rather than each of the
    512 bytes one time (!), which I'm guessing was the intent.

It was only through sheer luck that this worked in the first place.

Per Coverity static analysis performed by EnterpriseDB.
2005-06-22 02:00:47 +00:00
Tom Lane 7a28de2052 pg_dump can now dump large objects even in plain-text output mode, by
using the recently added lo_create() function.  The restore logic in
pg_restore is greatly simplified as well, since there's no need anymore
to try to adjust database references to match a new set of blob OIDs.
2005-06-21 20:45:44 +00:00
Tom Lane b49d871f6a Fix pg_dumpall to do the right thing with "postgres" database, per
Dave Page.  Also, cause it to emit rather than ignore any ACL and
datconfig options that may be set for these two databases.
2005-06-21 15:22:18 +00:00
Tom Lane 6f7fc0bade Cause initdb to create a third standard database "postgres", which
unlike template0 and template1 does not have any special status in
terms of backend functionality.  However, all external utilities such
as createuser and createdb now connect to "postgres" instead of
template1, and the documentation is changed to encourage people to use
"postgres" instead of template1 as a play area.  This should fix some
longstanding gotchas involving unexpected propagation of database
objects by createdb (when you used template1 without understanding
the implications), as well as ameliorating the problem that CREATE
DATABASE is unhappy if anyone else is connected to template1.
Patch by Dave Page, minor editing by Tom Lane.  All per recent
pghackers discussions.
2005-06-21 04:02:34 +00:00
Neil Conway 2d4b9736bb Trivial dead code removal: in _complete_from_query(), 'text' cannot be
NULL (e.g. due to the preceding strlen()). Therefore we needn't recheck
this before initializing 'e_text'.

Per Coverity static analysis performed by EnterpriseDB.
2005-06-21 00:48:33 +00:00
Bruce Momjian ba90268e2b Add comment about \# in bcc makefiles. 2005-06-19 13:14:20 +00:00
Bruce Momjian 624789d191 Cleanup for Win32 compile.
Andreas Pflug
2005-06-19 13:10:56 +00:00
Tom Lane d0a89683a3 Two-phase commit. Original patch by Heikki Linnakangas, with additional
hacking by Alvaro Herrera and Tom Lane.
2005-06-17 22:32:51 +00:00
Bruce Momjian b4132fd0ac Now \d show tablespace of indices per discussion.
test=# \d e
       Table "public.e"
 Column |  Type   | Modifiers
--------+---------+-----------
 i      | integer | not null
 j      | integer | not null
 k      | integer |
Indexes:
    "e_pkey" PRIMARY KEY, btree (i, j), tablespace "haha"
    "ei" btree (i)
    "ej" btree (j), tablespace "haha"
    "ek" btree (k)
Tablespace: "haha"

Qingqing Zhou
2005-06-14 23:59:31 +00:00
Bruce Momjian 921de09e40 Use ' ' escapes for leading spaces in table values, for use in
EXPLAIN output.

Jean-Paul Argudo
2005-06-14 22:15:57 +00:00
Bruce Momjian f04c39402a Attached is a makefile I hacked up to build pg_config under MSVC - the
reason is that it's required (more or less) in order to build the latest
DBD::Pg code and I was testing that out under MSVC.

Andrew Dunstan
2005-06-14 17:50:38 +00:00
Bruce Momjian 954f6bcffe Add GUC krb_server_hostname so the server hostname can be specified as
part of service principal.  If not set, any service principal matching
an entry in the keytab can be used.

NEW KERBEROS MATCHING BEHAVIOR FOR 8.1.

Todd Kover
2005-06-14 17:43:14 +00:00
Bruce Momjian 2ee0d5549f Add -L option to psql to log sessions.
Lorne Sunley
2005-06-14 02:57:45 +00:00
Neil Conway 077811605e Per discussion on -hackers, this patch changes psql's "expanded" output
mode to only affect the presentation of normal query results, not the
output of psql slash commands. Documentation updated. I also made
some unrelated minor psql cleanup. Per suggestion from Stuart Cooper.
2005-06-13 06:36:22 +00:00
Bruce Momjian 1a61896189 Use saveHistory so we get a nice error message on failure.
Andreas Seltenreich
2005-06-10 15:40:41 +00:00
Bruce Momjian ea88824a3e the following patch makes the filename used to store the readline
history customizable through a variable named HISTFILE, analogous to
psql's already implemented HISTCONTROL and HISTSIZE variables, and
bash's HISTFILE-Variable.

The motivation was to be able to get psql to maintain separate
histories for separate databases.  This is now easily achievable
through a line like the following in ~/.psqlrc:

\set HISTFILE ~/.psql_history-:DBNAME

Andreas Seltenreich
2005-06-10 15:34:26 +00:00
Bruce Momjian 92eadf6c4a More Win32 tilde code comments. 2005-06-10 14:49:31 +00:00
Bruce Momjian 3d44763179 Add comment on tilde expansion. 2005-06-10 14:41:32 +00:00
Bruce Momjian 0725065b37 This patch shows the full path name when doing a \s in psql,
if you have previously issued a \cd command.

Greg Sabino Mullane
2005-06-09 23:28:10 +00:00
Bruce Momjian 5c4955981e \(rs should be \\(rs, per Tom. 2005-06-09 18:40:06 +00:00
Bruce Momjian ebc8649892 Since I needed this feature badly, I added the -n / --schema switch to
pg_restore. It restores the given schemaname only. It can be used in
conjunction with the -t and other switches to make the selection very
fine grained.

Richard van den Bergg, CISSP
2005-06-09 17:56:51 +00:00
Bruce Momjian 4a5cda7bba I've created a patch which adds support for troff "-ms" output to
psql.  i.e. "\pset format troff-ms".  The patch also corrects some
problems with the "latex" format, notably defining an extra column in
the output table, and correcting some alignment issues; it also
changes the output to match the border setting as documented in the
manual page and as shown with the "aligned" format.

The troff-ms output is mostly identical to the latex output allowing
for the differences between the two typesetters.

The output should be saved in a file and piped as follows:

  cat file | tbl | troff -T ps -ms > file.ps
or
  tbl file | troff -T ps -ms > file.ps

Because it contains tabs, you'll need to redirect psql output or use
"script", rather than pasting from a terminal window, due to the tabs
which can be replaced with spaces.

Roger Leigh
2005-06-09 15:27:27 +00:00
Tom Lane f5b2f60bd1 Change WAL-logging scheme for multixacts to be more like regular
transaction IDs, rather than like subtrans; in particular, the information
now survives a database restart.  Per previous discussion, this is
essential for PITR log shipping and for 2PC.
2005-06-08 15:50:28 +00:00
Tom Lane c14f2ba7a4 Use just NULL not NULL::TEXT --- the latter coding is unnecessary and
not schema-safe.  Per report from Jochem van Dieten.
2005-06-07 14:04:48 +00:00
Tom Lane 8dfb616606 The no-lexer-backup speedup hadn't been there a week before somebody
broke it.  Maybe we do need an automated check ...
2005-06-02 17:45:19 +00:00
Tom Lane 21fda22ec4 Change CRCs in WAL records from 64bit to 32bit for performance reasons.
Instead of a separate CRC on each backup block, include backup blocks
in their parent WAL record's CRC; this is important to ensure that the
backup block really goes with the WAL record, ie there was not a page
tear right at the start of the backup block.  Implement a simple form
of compression of backup blocks: drop any run of zeroes starting at
pd_lower, so as not to store the unused 'hole' that commonly exists in
PG heap and index pages.  Tweak PageRepairFragmentation and related
routines to ensure they keep the unused space zeroed, so that the above
compression method remains effective.  All per recent discussions.
2005-06-02 05:55:29 +00:00
Bruce Momjian b51366396b Add support for \x hex strings in psql variables. 2005-06-02 01:23:48 +00:00
Bruce Momjian 3e8dbc846c Support only octal for psql PROMPT values, rather than the confusing
hex/decimal/octal.  Documentation already updated.

BACKWARD COMPATIBLE CHANGE
2005-05-30 18:28:11 +00:00
Bruce Momjian 33294d57c7 Use {xqoctesc} lex macro now that \ddd is standard. 2005-05-30 16:48:47 +00:00
Bruce Momjian f13c132072 Have psql escape bytes in strings for variables follow the backend
conventions of only allowing octal, like \045.  Remove support for
\decimal, \0octal, and \0xhex which matches the strtol() function but
didn't make sense with backslashes.

These now return the same character:

	test=> \set x '\54'
	test=> \echo :x
	,
	test=> \set x '\054'
	test=> \echo :x
	,

THIS IS A BACKWARD COMPATIBILITY CHANGE.
2005-05-30 14:50:35 +00:00
Tom Lane 15e4d1e2a7 Tweak the backend scanner (and psqlscan.l, which must track the backend
scanner anyway) to avoid having any backup states.  According to the
flex manual, this should speed things up, and indeed the backend scanner
is about a third faster according to some quick profiling checks.
I haven't tried to measure the speed change in psql, but it probably
is similar.
2005-05-26 01:24:29 +00:00
Bruce Momjian bbb586ff21 Quick patch to adress a recent concern on the mailing list
about adding an errant "TO" when we already have a TO. Since
TO cannot be a valid column name (we must quote it), we can
simply ignore the tab-completion if the previous word
was a "TO".

Greg Sabino Mullane
2005-05-25 22:12:05 +00:00
Bruce Momjian b492c3accc Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
2005-05-25 21:40:43 +00:00
Tom Lane 1a022f71d8 Add -I$(srcdir) to CPPFLAGS to make psqlscan.c compile in vpath builds.
Not sure why this hasn't been reported before; perhaps it is not needed
with newer gcc versions, but it definitely fails here.
2005-05-24 16:45:23 +00:00
Neil Conway 6910032a56 Upon closer inspection, Greg's psql tab completion patch leaks memory.
Fix the leak, and add a comment to note that the return value of
previous_word must be free'd.
2005-05-18 05:01:10 +00:00
Neil Conway 4c1f9a0f0b psql tab completion improvements, from Greg Sabino Mullane:
* Made DELETE into "DELETE FROM"
* Moved ANALZYE to the end of the list to ease EXPLAIN / VACUUM
  conflicts
* Removed the ANALYZE xx semicolon completion: we don't do that anywhere
  else
* Add DECLARE support
* Add parens for DROP AGGREGATE
* Add "CASCADE | RESTRICT" for DROP xx
* Make EXPLAIN <tab> a lot smarter
* GROUP "BY" and ORDER "BY"
* "ISOLATION" becomes "ISOLATION LEVEL"
* Fix error in which REVOKE xx ON yy was receiving "TO", now gets "FROM"
* Add GRANT/REVOKE xx ON yy TO/FROM choices: usernames, GROUP, PUBLIC
* PREPARE xx <tab> AS "SELECT | INSERT | UPDATE | DELETE"
* Add = at end of UPDATE xx SET yy
* Beef up VACUUM stuff
2005-05-18 04:47:40 +00:00
Tom Lane f9ad8a2802 Guard against duplicate IDs in input file in SortTocFromFile().
Per report from Brian Hackett.
2005-05-17 17:30:29 +00:00