Commit Graph

35267 Commits

Author SHA1 Message Date
Stephen Frost
b68a1fc7ff Be sure to close() file descriptor on error case
In receivelog.c:writeTimeLineHistoryFile(), we were not properly
closing the open'd file descriptor in error cases.  While this
wouldn't matter much if we were about to exit due to such an
error, that's not the case with pg_receivexlog as it can be a
long-running process and these errors are non-fatal.

This resource leak was found by the Coverity scanner.

Back-patch to 9.3 where this issue first appeared.
2013-07-14 17:25:47 -04:00
Stephen Frost
e9010b9926 Ensure 64bit arithmetic when calculating tapeSpace
In tuplesort.c:inittapes(), we calculate tapeSpace by first figuring
out how many 'tapes' we can use (maxTapes) and then multiplying the
result by the tape buffer overhead for each.  Unfortunately, when
we are on a system with an 8-byte long, we allow work_mem to be
larger than 2GB and that allows maxTapes to be large enough that the
32bit arithmetic can overflow when multiplied against the buffer
overhead.

When this overflow happens, we end up adding the overflow to the
amount of space available, causing the amount of memory allocated to
be larger than work_mem.

Note that to reach this point, you have to set work mem to at least
24GB and be sorting a set which is at least that size.  Given that a
user who can set work_mem to 24GB could also set it even higher, if
they were looking to run the system out of memory, this isn't
considered a security issue.

This overflow risk was found by the Coverity scanner.

Back-patch to all supported branches, as this issue has existed
since before 8.4.
2013-07-14 16:42:58 -04:00
Peter Eisentraut
5ab811106b pg_isready: Message improvement 2013-07-14 16:08:41 -04:00
Stephen Frost
f5acde9380 pg_receivexlog - Exit on failure to parse
In streamutil.c:GetConnection(), upgrade failure to parse the
connection string to an exit(1) instead of simply returning NULL.
Most callers already immediately exited, but pg_receivexlog would
loop on this case, continually trying to re-parse the connection
string (which can't be changed after pg_receivexlog has started).

GetConnection() was already expected to exit(1) in some cases
(eg: failure to allocate memory or if unable to determine the
integer_datetimes flag), so this change shouldn't surprise anyone.

Began looking at this due to the Coverity scanner complaining that
we were leaking err_msg in this case- no longer an issue since we
just exit(1) immediately.
2013-07-14 15:38:43 -04:00
Stephen Frost
8839e7362c During parallel pg_dump, free commands from master
The command strings read by the child processes during parallel
pg_dump, after being read and handled, were not being free'd.
This patch corrects this relatively minor memory leak.

Leak found by the Coverity scanner.

Back patch to 9.3 where parallel pg_dump was introduced.
2013-07-14 14:36:26 -04:00
Noah Misch
fb7c0ac42e Switch user ID to the object owner when populating a materialized view.
This makes superuser-issued REFRESH MATERIALIZED VIEW safe regardless of
the object's provenance.  REINDEX is an earlier example of this pattern.
As a downside, functions called from materialized views must tolerate
running in a security-restricted operation.  CREATE MATERIALIZED VIEW
need not change user ID.  Nonetheless, avoid creation of materialized
views that will invariably fail REFRESH by making it, too, start a
security-restricted operation.

Back-patch to 9.3 so materialized views have this from the beginning.

Reviewed by Kevin Grittner.
2013-07-12 18:25:41 -04:00
Peter Eisentraut
7484f89daa pg_dump: Formatting cleanup of new messages 2013-07-11 21:48:31 -04:00
Bruce Momjian
02e61a8488 pg_upgrade: document possible pg_hba.conf options
Previously, pg_upgrade docs recommended using .pgpass if using MD5
authentication to avoid being prompted for a password.  Turns out pg_ctl
never prompts for a password, so MD5 requires .pgpass --- document that.
Also recommend 'peer' for authentication too.
Backpatch back to 9.1.
2013-07-11 09:43:19 -04:00
Peter Eisentraut
583435d079 doc: Replace link to pgFouine with pgBadger
From: Ian Lawrence Barwick <barwick@gmail.com>
2013-07-10 22:41:37 -04:00
Peter Eisentraut
bf470b37cc Fix lack of message pluralization 2013-07-09 21:04:55 -04:00
Michael Meskes
d0450f1fa6 Fixed incorrect description of EXEC SQL VAR command.
Thanks to MauMau <maumau307@gmail.com> for finding and fixing this.
2013-07-09 15:48:39 +02:00
Alvaro Herrera
469feb7afb Fix mention of htup.h in pageinspect docs
It's htup_details.h now.

Jeff Janes
2013-07-08 17:11:55 -04:00
Tom Lane
8b6191e1d5 Fix planning of parameterized appendrel paths with expensive join quals.
The code in set_append_rel_pathlist() for building parameterized paths
for append relations (inheritance and UNION ALL combinations) supposed
that the cheapest regular path for a child relation would still be cheapest
when reparameterized.  Which might not be the case, particularly if the
added join conditions are expensive to compute, as in a recent example from
Jeff Janes.  Fix it to compare child path costs *after* reparameterizing.
We can short-circuit that if the cheapest pre-existing path is already
parameterized correctly, which seems likely to be true often enough to be
worth checking for.

Back-patch to 9.2 where parameterized paths were introduced.
2013-07-07 22:37:28 -04:00
Peter Eisentraut
95b4e8761e pg_isready: Make --help output more consistent with other utilities 2013-07-07 16:08:45 -04:00
Peter Eisentraut
8ca0e6870c pg_resetxlog: Make --help consistent with man page
Use "MXID" as placeholder for -m option, instead of just "XID".
2013-07-07 16:08:45 -04:00
Bruce Momjian
bf8d8ddc08 pg_upgrade: document link options
Document that tablespaces and pg_xlog can be on different file systems
for pg_upgrade --link mode.
Backpatch to 9.3.
2013-07-07 15:58:07 -04:00
Magnus Hagander
9f8830dbe2 Fix include-guard
Looks like a cut/paste error in the original addition of the file.

Andres Freund
2013-07-07 13:38:27 +02:00
Michael Meskes
7428a260f6 Also escape double quotes for ECPG's #line statement. 2013-07-06 22:11:14 +02:00
Tom Lane
e407192c93 Rename a function to avoid naming conflict in parallel regression tests.
Commit 31a891857a added some tests in
plpgsql.sql that used a function rather unthinkingly named "foo()".
However, rangefuncs.sql has some much older tests that create a function
of that name, and since these test scripts run in parallel, there is a
chance of failures if the timing is just right.  Use another name to
avoid that.  Per buildfarm (failure seen today on "hamerkop", but
probably it's happened before and not been noticed).
2013-07-06 11:16:53 -04:00
Michael Meskes
7d114fb46f Applied patch by MauMau <maumau307@gmail.com> to escape filenames in #line statements. 2013-07-06 11:49:33 +02:00
Noah Misch
cf183732d2 Update messages, comments and documentation for materialized views.
All instances of the verbiage lagging the code.  Back-patch to 9.3,
where materialized views were introduced.
2013-07-05 15:26:46 -04:00
Magnus Hagander
462b562ab2 Remove stray | character
Erikjan Rijkers
2013-07-05 16:21:26 +02:00
Bruce Momjian
8b4c798973 Add contrib function references in the doc index
Backpatch to 9.3.
Idea from Craig Ringer
2013-07-04 11:33:08 -04:00
Robert Haas
cdaf7bde97 docs: Clarify flag dependencies for background workers.
BGWORKER_BACKEND_DATABASE_CONNECTION can only be used if
BGWORKER_SHMEM_ACCESS is also used.

Michael Paquier, with some tweaks by me.
2013-07-04 11:15:01 -04:00
Peter Eisentraut
f960fae017 doc: Fix typo in event trigger documentation
From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2013-07-04 10:28:07 -04:00
Peter Eisentraut
775a9f3025 doc: Add event trigger C API documentation
From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
2013-07-03 21:07:00 -04:00
Bruce Momjian
d3cc1b2ff0 pg_buffercache: document column meanings
Improve documentation for usagecount and relforknumber.
Backpatch to 9.3
Suggestion from Satoshi Nagayasu
2013-07-03 14:25:06 -04:00
Tom Lane
654b702a1c Fix handling of auto-updatable views on inherited tables.
An INSERT into such a view should work just like an INSERT into its base
table, ie the insertion should go directly into that table ... not be
duplicated into each child table, as was happening before, per bug #8275
from Rushabh Lathia.  On the other hand, the current behavior for
UPDATE/DELETE seems reasonable: the update/delete traverses the child
tables, or not, depending on whether the view specifies ONLY or not.
Add some regression tests covering this area.

Dean Rasheed
2013-07-03 12:26:33 -04:00
Noah Misch
c21bb48d6f Expose object name error fields in PL/pgSQL.
Specifically, permit attaching them to the error in RAISE and retrieving
them from a caught error in GET STACKED DIAGNOSTICS.  RAISE enforces
nothing about the content of the fields; for its purposes, they are just
additional string fields.  Consequently, clarify in the protocol and
libpq documentation that the usual relationships between error fields,
like a schema name appearing wherever a table name appears, are not
universal.  This freedom has other applications; consider a FDW
propagating an error from an RDBMS having no schema support.

Back-patch to 9.3, where core support for the error fields was
introduced.  This prevents the confusion of having a release where libpq
exposes the fields and PL/pgSQL does not.

Pavel Stehule, lexical revisions by Noah Misch.
2013-07-03 07:30:15 -04:00
Peter Eisentraut
a74a977fb0 doc: Remove i18ngurus.com link
The web site is dead, and the Wayback Machine shows that it didn't have
much useful content before.
2013-07-02 20:33:17 -04:00
Peter Eisentraut
7f3cd29f8f doc: Arrange See Also links in more consistent order 2013-07-02 20:13:43 -04:00
Alvaro Herrera
061c7a3c7a Mention extra_float_digits in floating point docs
Make it easier for readers of the FP docs to find out about possibly
truncated values.

Per complaint from Tom Duffey in message
F0E0F874-C86F-48D1-AA2A-0C5365BF5118@trillitech.com

Author: Albe Laurenz
Reviewed by: Abhijit Menon-Sen
2013-07-02 13:13:56 -04:00
Heikki Linnakangas
ae8fc62406 Silence compiler warning in assertion-enabled builds.
With -Wtype-limits, gcc correctly points out that size_t can never be < 0.
Backpatch to 9.3 and 9.2. It's been like this forever, but in <= 9.1 you got
a lot other warnings with -Wtype-limits anyway (at least with my version of
gcc).

Andres Freund
2013-07-02 17:51:32 +03:00
Bruce Momjian
4d6ae6aaec pg_dump docs: use escaped double-quotes, for Windows
On Unix, you can embed double-quotes in single-quotes, and via versa.
However, on Windows, you can only escape double-quotes in double-quotes,
so use that in the pg_dump -t/table example.
Backpatch to 9.3.
Report from Mike Toews
2013-07-01 14:52:56 -04:00
Peter Eisentraut
95ffbce9a1 Fix cpluspluscheck in checksum code
C++ is more picky about comparing signed and unsigned integers.
2013-06-30 19:34:14 -04:00
Simon Riggs
452d0c2182 Change errcode for lock_timeout to match NOWAIT
Set errcode to ERRCODE_LOCK_NOT_AVAILABLE

Zoltán Bsöszörményi
2013-06-29 00:59:20 +01:00
Alvaro Herrera
5e1ed63ac2 Update pg_resetxlog's documentation on multixacts
I added some more functionality to it in 0ac5ad5134 but neglected to
add it to the docs.

Per Peter Eisentraut in message
1367112171.32604.4.camel@vanquo.pezone.net
2013-06-27 15:35:34 -04:00
Alvaro Herrera
deac50021b Document relminmxid and datminmxid
I introduced these new fields in 0ac5ad5134 but neglected to add them
to the system catalogs section of the docs.

Per Thom Brown in message
CAA-aLv7UiO=Whiq3MVbsEqSyQRthuX8Tb_RLyBuQt0KQBp=6EQ@mail.gmail.com
2013-06-27 15:35:32 -04:00
Tom Lane
fc469af248 Mark index-constraint comments with correct dependency in pg_dump.
When there's a comment on an index that was created with UNIQUE or PRIMARY
KEY constraint syntax, we need to label the comment as depending on the
constraint not the index, since only the constraint object actually appears
in the dump.  This incorrect dependency can lead to parallel pg_restore
trying to restore the comment before the index has been created, per bug
#8257 from Lloyd Albin.

This patch fixes pg_dump to produce the right dependency in dumps made
in the future.  Usually we also try to hack pg_restore to work around
bogus dependencies, so that existing (wrong) dumps can still be restored in
parallel mode; but that doesn't seem practical here since there's no easy
way to relate the constraint dump entry to the comment after the fact.

Andres Freund
2013-06-27 13:54:55 -04:00
Tom Lane
0b173ced93 Expect EWOULDBLOCK from a non-blocking connect() call only on Windows.
On Unix-ish platforms, EWOULDBLOCK may be the same as EAGAIN, which is
*not* a success return, at least not on Linux.  We need to treat it as a
failure to avoid giving a misleading error message.  Per the Single Unix
Spec, only EINPROGRESS and EINTR returns indicate that the connection
attempt is in progress.

On Windows, on the other hand, EWOULDBLOCK (WSAEWOULDBLOCK) is the expected
case.  We must accept EINPROGRESS as well because Cygwin will return that,
and it doesn't seem worth distinguishing Cygwin from native Windows here.
It's not very clear whether EINTR can occur on Windows, but let's leave
that part of the logic alone in the absence of concrete trouble reports.

Also, remove the test for errno == 0, effectively reverting commit
da9501bddb, which AFAICS was just a thinko;
or at best it might have been a workaround for a platform-specific bug,
which we can hope is gone now thirteen years later.  In any case, since
libpq makes no effort to reset errno to zero before calling connect(),
it seems unlikely that that test has ever reliably done anything useful.

Andres Freund and Tom Lane
2013-06-27 12:37:01 -04:00
Tom Lane
4b2deb7256 Tweak wording in sequence-function docs to avoid PDF build failures.
Adjust the wording in the first para of "Sequence Manipulation Functions"
so that neither of the link phrases in it break across line boundaries,
in either A4- or US-page-size PDF output.  This fixes a reported build
failure for the 9.3beta2 A4 PDF docs, and future-proofs this particular
para against causing similar problems in future.  (Perhaps somebody will
fix this issue in the SGML/TeX documentation tool chain someday, but I'm
not holding my breath.)

Back-patch to all supported branches, since the same problem could rise up
to bite us in future updates if anyone changes anything earlier than this
in func.sgml.
2013-06-27 00:23:56 -04:00
Noah Misch
40265e3446 Document effect of constant folding on CASE.
Back-patch to all supported versions.

Laurenz Albe
2013-06-26 20:33:25 -04:00
Peter Eisentraut
dc22b34f86 pg_receivexlog: Fix logic error
The code checking the WAL file name contained a logic error and wouldn't
actually catch some bad names.
2013-06-26 00:02:01 -04:00
Alvaro Herrera
cb687c751c Avoid inconsistent type declaration
Clang 3.3 correctly complains that a variable of type enum
MultiXactStatus cannot hold a value of -1, which makes sense.  Change
the declared type of the variable to int instead, and apply casting as
necessary to avoid the warning.

Per notice from Andres Freund
2013-06-25 16:42:06 -04:00
Andrew Dunstan
a20d7c3bc3 Properly dump dropped foreign table cols in binary-upgrade mode.
In binary upgrade mode, we need to recreate and then drop dropped
columns so that all the columns get the right attribute number. This is
true for foreign tables as well as for native tables. For foreign
tables we have been getting the first part right but not the second,
leading to bogus columns in the upgraded database. Fix this all the way
back to 9.1, where foreign tables were introduced.
2013-06-25 13:46:10 -04:00
Fujii Masao
0b958f3efc Support clean switchover.
In replication, when we shutdown the master, walsender tries to send
all the outstanding WAL records to the standby, and then to exit. This
basically means that all the WAL records are fully synced between
two servers after the clean shutdown of the master. So, after
promoting the standby to new master, we can restart the stopped
master as new standby without the need for a fresh backup from
new master.

But there was one problem so far: though walsender tries to send all
the outstanding WAL records, it doesn't wait for them to be replicated
to the standby. Then, before receiving all the WAL records,
walreceiver can detect the closure of connection and exit. We cannot
guarantee that there is no missing WAL in the standby after clean
shutdown of the master. In this case, backup from new master is
required when restarting the stopped master as new standby.

This patch fixes this problem. It just changes walsender so that it
waits for all the outstanding WAL records to be replicated to the
standby before closing the replication connection.

Per discussion, this is a fix that needs to get backpatched rather than
new feature. So, back-patch to 9.1 where enough infrastructure for
this exists.

Patch by me, reviewed by Andres Freund.
2013-06-26 02:18:26 +09:00
Peter Eisentraut
09bd2acbe5 Stamp 9.3beta2. 2013-06-24 14:55:41 -04:00
Peter Eisentraut
060ffab6b9 Translation updates 2013-06-24 14:16:15 -04:00
Simon Riggs
7b2c9d6829 Ensure no xid gaps during Hot Standby startup
In some cases with higher numbers of subtransactions
it was possible for us to incorrectly initialize
subtrans leading to complaints of missing pages.

Bug report by Sergey Konoplev
Analysis and fix by Andres Freund
2013-06-23 11:09:24 +01:00
Peter Eisentraut
0b5a5c8e05 doc: Fix date in EPUB manifest
If there is no <date> element, the publication date for the EPUB
manifest is taken from the copyright year.  But something like
"1996-2013" is not a legal date specification.  So the EPUB output
currently fails epubcheck.

Put in a separate <date> element with the current year.  Put it in
legal.sgml, because copyright.pl already instructs to update that
manually, so it hopefully won't be missed.
2013-06-21 22:53:24 -04:00