Commit Graph

3567 Commits

Author SHA1 Message Date
Magnus Hagander a0b4c5a20a Fix pg_basebackup/pg_receivexlog for floating point timestamps
Since the replication protocol deals with TimestampTz, we need to
care for the floating point case as well in the frontend tools.

Fujii Masao, with changes from Magnus Hagander
2012-06-10 12:12:36 +02:00
Magnus Hagander 7c1abc00fa Error message capitalization fix 2012-06-10 12:02:52 +02:00
Peter Eisentraut 5d0109bd27 Message style improvements 2012-06-07 23:54:59 +03:00
Magnus Hagander 92135ea0ed Use strerror(errno) instead of %m
Found by Fujii Masao
2012-06-05 15:52:08 +02:00
Tom Lane d73b7f973d Fix memory leaks in failure paths in buildACLCommands and parseAclItem.
This is currently only cosmetic, since all the call sites just curl up
and die in event of a failure return.  It might be important for some
future use-case, though, and in any case it quiets warnings from the
clang static analyzer (as reported by Anna Zaks).

Josh Kupershmidt
2012-06-03 11:52:52 -04:00
Tom Lane 4317e0246c Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings.  This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt.  (And I'm not totally convinced there weren't
other bugs, either.)  Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().

To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field.  This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.

Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject().  This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.

Minor other code review for the patch, too.
2012-05-29 23:22:14 -04:00
Tom Lane c89bdf7690 Eliminate some more O(N^2) behaviors in pg_dump/pg_restore.
This patch fixes three places (which AFAICT is all of them) where runtime
was O(N^2) in the number of TOC entries, by using an index array to replace
linear searches of the TOC list.  This performance issue is a bit less bad
than those recently fixed, because it depends on the number of items dumped
not the number in the source database, so the problem can be dodged by
doing partial dumps.

The previous coding already had an instance of one of the two index arrays
needed, but it was only calculated in parallel-restore cases; now we need
it all the time.  I also chose to move the arrays into the ArchiveHandle
data structure, to make this code a bit more ready for the day that we
try to sling multiple ArchiveHandles around in pg_dump or pg_restore.

Since we still need some server-side work before pg_dump can really cope
nicely with tens of thousands of tables, there's probably little point in
back-patching.
2012-05-28 20:38:28 -04:00
Peter Eisentraut 8e497c731b psql: Remove notice about readline from --version output
This was from a time when readline support wasn't standard.  And it
doesn't help analyzing current line editing library problems.
2012-05-27 22:48:20 +03:00
Magnus Hagander 16282ae688 Make pg_recievexlog by default loop on connection failures
Avoids the need for an external script in the most common
scenario. Behavior can be overridden using the -n/--noloop
commandline parameter.
2012-05-27 11:05:24 +02:00
Tom Lane 73cc7d3b24 Use binary search instead of brute-force scan in findNamespace().
The previous coding presented a significant bottleneck when dumping
databases containing many thousands of schemas, since the total time
spent searching would increase roughly as O(N^2) in the number of objects.
Noted by Jeff Janes, though I rewrote his proposed patch to use the
existing findObjectByOid infrastructure.

Since this is a longstanding performance bug, backpatch to all supported
versions.
2012-05-25 14:35:37 -04:00
Magnus Hagander 31d965819b Fix base backup streaming xlog from standby
When backing up from a standby server, the backup process
will not automatically switch xlog segment. So we must
accept a partially transferred xlog file in this case, but
rename it into position anyway.

In passing, merge the two callbacks for segment end and
stop stream into a single callback, since their implementations
were close to identical, and rename this callback to
reflect that it stops streaming rather than continues it.

Patch by Magnus Hagander, review by Fujii Masao
2012-05-25 11:36:22 +02:00
Magnus Hagander 77f93cb32d Add missing PQfinish() calls
Fujii Masao
2012-05-23 21:52:23 +02:00
Robert Haas 304aa339b2 Prevent pg_basebackup when integer_datetimes flag doesn't match.
Magnus Hagander, reviewed by Fujii Masao, with slight wording changes
by me.
2012-05-22 10:02:47 -04:00
Peter Eisentraut cdf8bcb8d9 pg_ctl: Sort signal list in --help output
The list was neither logical nor numerical nor alphabetical.  Let's go
with alphabetical.
2012-05-21 20:12:30 +03:00
Peter Eisentraut 2273a50364 Realign some --help output to have better spacing between columns 2012-05-18 20:34:14 +03:00
Peter Eisentraut 2a7f636640 pg_ctl: Improve --help output
All other --help output has = signs between long options and their
arguments, so do it here as well.
2012-05-14 04:50:39 +03:00
Magnus Hagander f33c5d471c Only attempt to show collations on servers >= 9.1.
Show a proper error message instead of a SQL error.

Josh Kupershmidt
2012-05-10 09:12:26 +02:00
Peter Eisentraut db84ba65ab psql: Add variable to control keyword case in tab completion
This adds the variable COMP_KEYWORD_CASE, which controls in what case
keywords are completed.  This is partially to let users configure the
change from commit 69f4f1c357, but it
also offers more behaviors than were available before.
2012-05-08 21:06:08 +03: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 cc71ceab57 psql: Tab completion updates
Add/complete support for:

- ALTER DOMAIN / VALIDATE CONSTRAINT
- ALTER DOMAIN / RENAME
- ALTER DOMAIN / RENAME CONSTRAINT
- ALTER TABLE / RENAME CONSTRAINT
2012-04-26 20:07:40 +03:00
Robert Haas 5d4b60f2f2 Lots of doc corrections.
Josh Kupershmidt
2012-04-23 22:43:09 -04:00
Alvaro Herrera 09ff76fcdb Recast "ONLY" column CHECK constraints as NO INHERIT
The original syntax wasn't universally loved, and it didn't allow its
usage in CREATE TABLE, only ALTER TABLE.  It now works everywhere, and
it also allows using ALTER TABLE ONLY to add an uninherited CHECK
constraint, per discussion.

The pg_constraint column has accordingly been renamed connoinherit.

This commit partly reverts some of the changes in
61d81bd28d, particularly some pg_dump and
psql bits, because now pg_get_constraintdef includes the necessary NO
INHERIT within the constraint definition.

Author: Nikhil Sontakke
Some tweaks by me
2012-04-20 23:56:57 -03:00
Peter Eisentraut 1fd832ddff psql: Add tab completion for CREATE/ALTER ROLE name WITH
Previously, the use of the optional key word WITH was not supported.

Josh Kupershmidt
2012-04-18 16:55:01 +03:00
Andrew Dunstan 1b37a8c3cc Don't override arguments set via options with positional arguments.
A number of utility programs were rather careless about paremeters
that can be set via both an option argument and a positional
argument. This leads to results which can violate the Principal
Of Least Astonishment. These changes refuse to use positional
arguments to override settings that have been made via positional
arguments. The changes are backpatched to all live branches.
2012-04-17 18:30:34 -04:00
Tatsuo Ishii 4efbb7d04f Add missing descriptions about '--timeout' and '--mode' to help
message. They are already implemented in the source code.
Suggestions about the message formatting from Tom Lane.
2012-04-15 09:17:12 +09:00
Peter Eisentraut 64e1309c76 Consistently quote encoding and locale names in messages 2012-04-13 20:37:07 +03:00
Peter Eisentraut 6b8c99c386 psql: Improve tab completion of WITH
Only match when WITH is the first word, as WITH may appear in many
other contexts.

Josh Kupershmidt
2012-04-10 20:35:39 +03:00
Tom Lane 263d9de66b Allow statistics to be collected for foreign tables.
ANALYZE now accepts foreign tables and allows the table's FDW to control
how the sample rows are collected.  (But only manual ANALYZEs will touch
foreign tables, for the moment, since among other things it's not very
clear how to handle remote permissions checks in an auto-analyze.)

contrib/file_fdw is extended to support this.

Etsuro Fujita, reviewed by Shigeru Hanada, some further tweaking by me.
2012-04-06 15:02:35 -04:00
Robert Haas 662ca285a6 Put back code inadvertently deleted from exit_nicely.
Report by Andrew Dunstan.
2012-04-05 21:37:33 -04:00
Tom Lane a75b08066a Update obsolete comment.
Somebody didn't bother to fix this comment while adding foreign table
support to the code below it.

In passing, remove the explicit calling-out of relkind letters, which adds
complexity to the comment but doesn't help in understanding the code.
2012-04-05 13:05:02 -04:00
Tom Lane cb917e1544 Remove useless PGRES_COPY_BOTH "support" in psql.
There is no existing or foreseeable case in which psql should see a
PGRES_COPY_BOTH PQresultStatus; and if such a case ever emerges, it's a
pretty good bet that these code fragments wouldn't do the right thing
anyway.  Remove them, and let the existing default cases do the appropriate
thing, namely emit an "unexpected PQresultStatus" bleat.

Noted while working on libpq row processor patch, for which I was
considering adding a PGRES_SUSPENDED status code --- the same default-case
treatment would be appropriate for that.
2012-04-04 16:15:04 -04:00
Robert Haas 5e86c61a7e Arrange for on_exit_nicely to be thread-safe.
Extracted from Joachim Wieland's parallel pg_dump patch, with some
additional comments by me.
2012-04-03 08:39:03 -04:00
Peter Eisentraut 5633df2582 Fix recently introduced typo in NLS file lists 2012-04-02 02:39:34 +03:00
Tom Lane d5881c036a Fix O(N^2) behavior in pg_dump when many objects are in dependency loops.
Combining the loop workspace with the record of already-processed objects
might have been a cute trick, but it behaves horridly if there are many
dependency loops to repair: the time spent in the first step of findLoop()
grows as O(N^2).  Instead use a separate flag array indexed by dump ID,
which we can check in constant time.  The length of the workspace array
is now never more than the actual length of a dependency chain, which
should be reasonably short in all cases of practical interest.  The code
is noticeably easier to understand this way, too.

Per gripe from Mike Roest.  Since this is a longstanding performance bug,
backpatch to all supported versions.
2012-03-31 15:51:07 -04:00
Tom Lane 0d8117abef Fix O(N^2) behavior in pg_dump for large numbers of owned sequences.
The loop that matched owned sequences to their owning tables required time
proportional to number of owned sequences times number of tables; although
this work was only expended in selective-dump situations, which is probably
why the issue wasn't recognized long since.  Refactor slightly so that we
can perform this work after the index array for findTableByOid has been
set up, reducing the time to O(M log N).

Per gripe from Mike Roest.  Since this is a longstanding performance bug,
backpatch to all supported versions.
2012-03-31 14:42:17 -04:00
Tom Lane c252a17d82 Rename frontend keyword arrays to avoid conflict with backend.
ecpg and pg_dump each contain keyword arrays with structure similar
to the backend's keyword array.  Up to now, we actually named those
arrays the same as the backend's and relied on parser/keywords.h
to declare them.  This seems a tad too cute, though, and it breaks
now that we need to PGDLLIMPORT-decorate the backend symbols.
Rename to avoid the problem.  Per buildfarm.

(It strikes me that maybe we should get rid of the separate keywords.c
files altogether, and just define these arrays in the modules that use
them, but that's a rather more invasive change.)
2012-03-31 13:15:53 -04:00
Tom Lane a52e6fe7bc Fix glitch recently introduced in psql tab completion.
Over-optimization (by me, looks like :-() broke the case of recognizing
a word boundary just before a quoted identifier.  Reported and diagnosed
by Dean Rasheed.
2012-03-31 11:19:23 -04:00
Peter Eisentraut 194b5ea3d0 Add new files to NLS file lists
Some of these are newly added, some are older and were forgotten, some
don't contain any translatable strings right now but look like they
could in the future.
2012-03-30 20:46:23 +03:00
Peter Eisentraut 1d1361b6b7 Replace printf format %i by %d
see also ce8d7bb644
2012-03-30 20:40:46 +03:00
Peter Eisentraut 2005b77b8f initdb: Mark more messages for translation
Some Windows-only messages had apparently been forgotten so far.

Also make the wording of the messages more consistent with similar
messages other parts, such as pg_ctl and pg_regress.
2012-03-29 21:16:28 +03:00
Andrew Dunstan d2c1740dc2 Remove now redundant pgpipe code. 2012-03-28 23:24:07 -04:00
Robert Haas ada763cfcd pg_basebackup: Error handling fixes.
Thomas Ogrisegg and Fujii Masao
2012-03-28 12:19:22 -04:00
Robert Haas 81f6bbe8ad pg_basebackup: Error message improvements.
Fujii Masao
2012-03-28 08:43:35 -04:00
Peter Eisentraut dd024c22f1 pg_dump: Small message adjustment for consistency 2012-03-27 19:52:39 +03:00
Tom Lane c7cea267de Replace empty locale name with implied value in CREATE DATABASE and initdb.
setlocale() accepts locale name "" as meaning "the locale specified by the
process's environment variables".  Historically we've accepted that for
Postgres' locale settings, too.  However, it's fairly unsafe to store an
empty string in a new database's pg_database.datcollate or datctype fields,
because then the interpretation could vary across postmaster restarts,
possibly resulting in index corruption and other unpleasantness.

Instead, we should expand "" to whatever it means at the moment of calling
CREATE DATABASE, which we can do by saving the value returned by
setlocale().

For consistency, make initdb set up the initial lc_xxx parameter values the
same way.  initdb was already doing the right thing for empty locale names,
but it did not replace non-empty names with setlocale results.  On a
platform where setlocale chooses to canonicalize the spellings of locale
names, this would result in annoying inconsistency.  (It seems that popular
implementations of setlocale don't do such canonicalization, which is a
pity, but the POSIX spec certainly allows it to be done.)  The same risk
of inconsistency leads me to not venture back-patching this, although it
could certainly be seen as a longstanding bug.

Per report from Jeff Davis, though this is not his proposed patch.
2012-03-25 21:47:22 -04:00
Tom Lane ed61127be4 Cast some printf arguments to avoid possibly-nonportable behavior.
Per compiler warnings on buildfarm member black_firefly.
2012-03-23 20:18:04 -04:00
Tom Lane 04dfc87749 If a role has a password expiration date, show that in psql's \du output.
Per a suggestion from Euler Taveira, it seems like a good idea to include
this information in \du (and \dg) output.  This costs nothing for people
who are not using the VALID UNTIL feature, while for those who are, it's
rather critical information.

Fabrízio de Royes Mello
2012-03-22 02:08:25 -04:00
Peter Eisentraut 0e85abd658 Clean up compiler warnings from unused variables with asserts disabled
For those variables only used when asserts are enabled, use a new
macro PG_USED_FOR_ASSERTS_ONLY, which expands to
__attribute__((unused)) when asserts are not enabled.
2012-03-21 23:33:10 +02:00
Robert Haas 99081c63e4 Improve connectMaintenanceDatabase() error reporting.
The prior coding instructs the user to pick an alternative maintenance
database, but this is overly clever, since it obscures whatever the real
cause of the failure is.

Josh Kupershmidt
2012-03-21 10:56:26 -04:00
Alvaro Herrera 9d23a70d51 pg_dump: get rid of die_horribly
The old code was using exit_horribly or die_horribly other depending on
whether it had an ArchiveHandle on which to close the connection or not;
but there were places that were passing a NULL ArchiveHandle to
die_horribly, and other places that used exit_horribly while having an
AH available.  So there wasn't all that much consistency.

Improve the situation by keeping only one of the routines, and instead
of having to pass the AH down from the caller, arrange for it to be
present for an on_exit_nicely callback to operate on.

Author: Joachim Wieland
Some tweaks by me

Per a suggestion from Robert Haas, in the ongoing "parallel pg_dump"
saga.
2012-03-20 18:58:00 -03:00