OSDN Git Service

pg-rex/syncrep.git
13 years agoRevert "Add the definition of replication modes."
MasaoFujii [Mon, 22 Nov 2010 02:33:53 +0000 (11:33 +0900)]
Revert "Add the definition of replication modes."

This reverts commit 4b390ba3022a7515772a621001bbdf1d82d0e371.

This is for moving replication_mode from recovery.conf to postgresql.conf

13 years agoRevert "Add replication_mode parameter in recovery.conf."
MasaoFujii [Mon, 22 Nov 2010 02:32:04 +0000 (11:32 +0900)]
Revert "Add replication_mode parameter in recovery.conf."

This reverts commit 3293dd5337a258a00e1a65936e1e4d18a886e078.

This is for moving replication_mode from recovery.conf to
postgresql.conf.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Mon, 22 Nov 2010 02:11:25 +0000 (11:11 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Mon, 22 Nov 2010 02:06:42 +0000 (11:06 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoFix leakage of cost_limit when multiple autovacuum workers are active.
Tom Lane [Sat, 20 Nov 2010 03:28:25 +0000 (22:28 -0500)]
Fix leakage of cost_limit when multiple autovacuum workers are active.

When using default autovacuum_vac_cost_limit, autovac_balance_cost relied
on VacuumCostLimit to contain the correct global value ... but after the
first time through in a particular worker process, it didn't, because we'd
trashed it in previous iterations.  Depending on the state of other autovac
workers, this could result in a steady reduction of the effective
cost_limit setting as a particular worker processed more and more tables,
causing it to go slower and slower.  Spotted by Simon Poole (bug #5759).
Fix by saving and restoring the GUC variables in the loop in do_autovacuum.

In passing, improve a few comments.

Back-patch to 8.3 ... the cost rebalancing code has been buggy since it was
put in.

13 years agoImprove plpgsql's error reporting for no-such-column cases.
Tom Lane [Thu, 18 Nov 2010 22:06:57 +0000 (17:06 -0500)]
Improve plpgsql's error reporting for no-such-column cases.

Given a column reference foo.bar, where there is a composite plpgsql
variable foo but it doesn't contain a column bar, the pre-9.0 coding would
immediately throw a "record foo has no field bar" error.  In 9.0 the parser
hook instead falls through to let the core parser see if it can resolve the
reference.  If not, you get a complaint about "missing FROM-clause entry
for table foo", which while in some sense correct isn't terribly helpful.
Complicate things a bit so that we can throw the old error message if
neither the core parser nor the hook are able to resolve the column
reference, while not changing the behavior in any other case.
Per bug #5757 from Andrey Galkin.

13 years agoSend paramHandle to subprocesses as 64-bit on Win64
Magnus Hagander [Tue, 16 Nov 2010 11:40:56 +0000 (12:40 +0100)]
Send paramHandle to subprocesses as 64-bit on Win64

The handle to the shared memory segment containing startup
parameters was sent as 32-bit even on 64-bit systems. Since
HANDLEs appear to be allocated sequentially this shouldn't
be a problem until we reach 2^32 open handles in the postmaster,
but a 64-bit value should be sent across as 64-bit, and not
zero out the top 32 bits.

Noted by Tom Lane.

13 years agoThe GiST scan algorithm uses LSNs to detect concurrent pages splits, but
Heikki Linnakangas [Tue, 16 Nov 2010 09:02:11 +0000 (11:02 +0200)]
The GiST scan algorithm uses LSNs to detect concurrent pages splits, but
temporary indexes are not WAL-logged. We used a constant LSN for temporary
indexes, on the assumption that we don't need to worry about concurrent page
splits in temporary indexes because they're only visible to the current
session. But that assumption is wrong, it's possible to insert rows and
split pages in the same session, while a scan is in progress. For example,
by opening a cursor and fetching some rows, and INSERTing new rows before
fetching some more.

Fix by generating fake increasing LSNs, used in place of real LSNs in
temporary GiST indexes.

13 years agoFix aboriginal mistake in plpython's set-returning-function support.
Tom Lane [Mon, 15 Nov 2010 19:27:00 +0000 (14:27 -0500)]
Fix aboriginal mistake in plpython's set-returning-function support.

We must stay in the function's SPI context until done calling the iterator
that returns the set result.  Otherwise, any attempt to invoke SPI features
in the python code called by the iterator will malfunction.  Diagnosis and
patch by Jan Urbanski, per bug report from Jean-Baptiste Quenot.

Back-patch to 8.2; there was no support for SRFs in previous versions of
plpython.

13 years agoAvoid spurious Hot Standby conflicts from btree delete records.
Simon Riggs [Mon, 15 Nov 2010 09:31:23 +0000 (09:31 +0000)]
Avoid spurious Hot Standby conflicts from btree delete records.
Similar conflicts were already avoided for related record types.
Massive over-caution resulted in a usability bug. Clear theoretical
basis for doing this is now confirmed by me.
Request to remove from Heikki (twice), over-caution by me.

13 years agoFix bug in cube picksplit algorithm.
Robert Haas [Mon, 15 Nov 2010 02:27:34 +0000 (21:27 -0500)]
Fix bug in cube picksplit algorithm.

Alexander Korotkov

13 years agoFix canAcceptConnections() bugs introduced by replication-related patches.
Tom Lane [Sun, 14 Nov 2010 20:57:42 +0000 (15:57 -0500)]
Fix canAcceptConnections() bugs introduced by replication-related patches.

We must not return any "okay to proceed" result code without having checked
for too many children, else we might fail later on when trying to add the
new child to one of the per-child state arrays.  It's not clear whether
this oversight explains Stefan Kaltenbrunner's recent report, but it could
certainly produce a similar symptom.

Back-patch to 8.4; the logic was not broken before that.

13 years agoAdd missing outfuncs.c support for struct InhRelation.
Tom Lane [Sat, 13 Nov 2010 05:34:50 +0000 (00:34 -0500)]
Add missing outfuncs.c support for struct InhRelation.

This is needed to support debug_print_parse, per report from Jon Nelson.
Cursory testing via the regression tests suggests we aren't missing
anything else.

13 years agoFix old oversight in const-simplification of COALESCE() expressions.
Tom Lane [Fri, 12 Nov 2010 20:14:51 +0000 (15:14 -0500)]
Fix old oversight in const-simplification of COALESCE() expressions.

Once we have found a non-null constant argument, there is no need to
examine additional arguments of the COALESCE.  The previous coding got it
right only if the constant was in the first argument position; otherwise
it tried to simplify following arguments too, leading to unexpected
behavior like this:

regression=# select coalesce(f1, 42, 1/0) from int4_tbl;
ERROR:  division by zero

It's a minor corner case, but a bug is a bug, so back-patch all the way.

13 years agodocs -> documentation
Peter Eisentraut [Fri, 12 Nov 2010 19:25:57 +0000 (21:25 +0200)]
docs -> documentation

13 years agoAdd replication_mode parameter in recovery.conf.
MasaoFujii [Fri, 12 Nov 2010 17:43:58 +0000 (02:43 +0900)]
Add replication_mode parameter in recovery.conf.

13 years agoProvide the capability to signal the reason when setting the latch.
MasaoFujii [Fri, 12 Nov 2010 14:23:21 +0000 (23:23 +0900)]
Provide the capability to signal the reason when setting the latch.

13 years agoReplace obsolete function named CheckClosedConnection with new one
MasaoFujii [Fri, 12 Nov 2010 14:20:36 +0000 (23:20 +0900)]
Replace obsolete function named CheckClosedConnection with new one
named ProcessStreamMsgs.

13 years agoAdd the definition of replication modes.
MasaoFujii [Fri, 12 Nov 2010 13:37:29 +0000 (22:37 +0900)]
Add the definition of replication modes.

13 years agoAdd missing support for removing foreign data wrapper / server privileges
Heikki Linnakangas [Fri, 12 Nov 2010 13:19:14 +0000 (15:19 +0200)]
Add missing support for removing foreign data wrapper / server privileges
belonging to a user at DROP OWNED BY. Foreign data wrappers and servers
don't do anything useful yet, which is why no-one has noticed, but since we
have them, seems prudent to fix this. Per report from Chetan Suttraway.
Backpatch to 9.0, 8.4 has the same problem but this patch didn't apply
there so I'm not going to bother.

13 years agoRemove a junk space.
MasaoFujii [Fri, 12 Nov 2010 13:20:37 +0000 (22:20 +0900)]
Remove a junk space.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Fri, 12 Nov 2010 13:10:15 +0000 (22:10 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Fri, 12 Nov 2010 13:09:44 +0000 (22:09 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoFix bug introduced by the recent patch to check that the checkpoint redo
Heikki Linnakangas [Thu, 11 Nov 2010 17:21:49 +0000 (19:21 +0200)]
Fix bug introduced by the recent patch to check that the checkpoint redo
location read from backup label file can be found: wasShutdown was set
incorrectly when a backup label file was found.

Jeff Davis, with a little tweaking by me.

13 years agoFix line_construct_pm() for the case of "infinite" (DBL_MAX) slope.
Tom Lane [Wed, 10 Nov 2010 21:51:39 +0000 (16:51 -0500)]
Fix line_construct_pm() for the case of "infinite" (DBL_MAX) slope.

This code was just plain wrong: what you got was not a line through the
given point but a line almost indistinguishable from the Y-axis, although
not truly vertical.  The only caller that tries to use this function with
m == DBL_MAX is dist_ps_internal for the case where the lseg is horizontal;
it would end up producing the distance from the given point to the place
where the lseg's line crosses the Y-axis.  That function is used by other
operators too, so there are several operators that could compute wrong
distances from a line segment to something else.  Per bug #5745 from
jindiax.

Back-patch to all supported branches.

13 years agoMention that pg_upgrade requires compatible 32/64-bit binaries.
Bruce Momjian [Wed, 10 Nov 2010 14:33:37 +0000 (14:33 +0000)]
Mention that pg_upgrade requires compatible 32/64-bit binaries.

13 years agoMerge branch 'pgrex90-base' into pgrex90
MasaoFujii [Wed, 10 Nov 2010 13:19:41 +0000 (22:19 +0900)]
Merge branch 'pgrex90-base' into pgrex90

13 years agoMake startup process respond to signals to cancel waiting on latch.
Simon Riggs [Thu, 14 Oct 2010 18:15:26 +0000 (19:15 +0100)]
Make startup process respond to signals to cancel waiting on latch.
A tidy up for recently committed changes to startup latch.

Fujii Masao

13 years agoMerge branch 'REL9_0_STABLE' into pgrex90-base
MasaoFujii [Wed, 10 Nov 2010 12:55:42 +0000 (21:55 +0900)]
Merge branch 'REL9_0_STABLE' into pgrex90-base

13 years agoDon't use __declspec (dllimport) for PGDLLEXPORT to reduce warnings
Itagaki Takahiro [Wed, 10 Nov 2010 03:17:43 +0000 (12:17 +0900)]
Don't use __declspec (dllimport) for PGDLLEXPORT to reduce warnings
by gcc version 4 on mingw and cygwin. We don't use dllexport here
because dllexport and dllwrap don't work well together.

13 years agoRepair memory leakage while ANALYZE-ing complex index expressions.
Tom Lane [Tue, 9 Nov 2010 16:28:18 +0000 (11:28 -0500)]
Repair memory leakage while ANALYZE-ing complex index expressions.

The general design of memory management in Postgres is that intermediate
results computed by an expression are not freed until the end of the tuple
cycle.  For expression indexes, ANALYZE has to re-evaluate each expression
for each of its sample rows, and it wasn't bothering to free intermediate
results until the end of processing of that index.  This could lead to very
substantial leakage if the intermediate results were large, as in a recent
example from Jakub Ouhrabka.  Fix by doing ResetExprContext for each sample
row.  This necessitates adding a datumCopy step to ensure that the final
expression value isn't recycled too.  Some quick testing suggests that this
change adds at worst about 10% to the time needed to analyze a table with
an expression index; which is annoying, but seems a tolerable price to pay
to avoid unexpected out-of-memory problems.

Back-patch to all supported branches.

13 years agoIn rewriteheap.c (used by VACUUM FULL and CLUSTER), calculate the tuple
Heikki Linnakangas [Tue, 9 Nov 2010 15:40:09 +0000 (17:40 +0200)]
In rewriteheap.c (used by VACUUM FULL and CLUSTER), calculate the tuple
length stored in the line pointer the same way it's calculated in the normal
heap_insert() codepath. As noted by Jeff Davis, the length stored by
raw_heap_insert() included padding but the one stored by the normal codepath
did not. While the mismatch seems to be harmless, inconsistency isn't good,
and the normal codepath has received a lot more testing over the years.

Backpatch to 8.3 where the heap rewrite code was introduced.

13 years agoplpython has plpy.Error instead of plpy.ERROR
Alvaro Herrera [Tue, 9 Nov 2010 14:00:56 +0000 (11:00 -0300)]
plpython has plpy.Error instead of plpy.ERROR

Author: Marti Raudsepp <marti@juffo.org>

13 years agoFix error handling in temp-file deletion with log_temp_files active.
Tom Lane [Tue, 9 Nov 2010 03:14:55 +0000 (22:14 -0500)]
Fix error handling in temp-file deletion with log_temp_files active.

The original coding in FileClose() reset the file-is-temp flag before
unlinking the file, so that if control came back through due to an error,
it wouldn't try to unlink the file twice.  This was correct when written,
but when the log_temp_files feature was added, the logging action was put
in between those two steps.  An error occurring during the logging action
--- such as a query cancel --- would result in the unlink not getting done
at all, as in recent report from Michael Glaesemann.

To fix this, make sure that we do both the stat and the unlink before doing
anything that could conceivably CHECK_FOR_INTERRUPTS.  There is a judgment
call here, which is which log message to emit first: if you can see only
one, which should it be?  I chose to log unlink failure at the risk of
losing the log_temp_files log message --- after all, if the unlink does
fail, the temp file is still there for you to see.

Back-patch to all versions that have log_temp_files.  The code was OK
before that.

13 years agoFix permanent memory leak in autovacuum launcher
Alvaro Herrera [Mon, 8 Nov 2010 21:35:42 +0000 (18:35 -0300)]
Fix permanent memory leak in autovacuum launcher

get_database_list was uselessly allocating its output data, along some
created along the way, in a permanent memory context.  This didn't
matter when autovacuum was a single, short-lived process, but now that
the launcher is permanent, it shows up as a permanent leak.

To fix, make get_database list allocate its output data in the caller's
context, which is in charge of freeing it when appropriate; and the
memory leaked by heap_beginscan et al is allocated in a throwaway
transaction context.

13 years agoAdd support for detecting register-stack overrun on IA64.
Tom Lane [Sun, 7 Nov 2010 02:59:09 +0000 (22:59 -0400)]
Add support for detecting register-stack overrun on IA64.

Per recent investigation, the register stack can grow faster than the
regular stack depending on compiler and choice of options.  To avoid
crashes we must check both stacks in check_stack_depth().

Back-patch to all supported versions.

13 years agoReduce recursion depth in recently-added regression test.
Tom Lane [Wed, 3 Nov 2010 17:41:53 +0000 (13:41 -0400)]
Reduce recursion depth in recently-added regression test.

Some buildfarm members fail the test with the original depth of 10 levels,
apparently because they are running at the minimum max_stack_depth setting
of 100kB and using ~ 10k per recursion level.  While it might be
interesting to try to figure out why they're eating so much stack, it isn't
likely that any fix for that would be back-patchable.  So just change the
test to recurse only 5 levels.  The extra levels don't prove anything
correctness-wise anyway.

13 years agoFix adjust_semi_join to be more cautious about clauseless joins.
Tom Lane [Tue, 2 Nov 2010 22:45:44 +0000 (18:45 -0400)]
Fix adjust_semi_join to be more cautious about clauseless joins.

It was reporting that these were fully indexed (hence cheap), when of
course they're the exact opposite of that.  I'm not certain if the case
would arise in practice, since a clauseless semijoin is hard to produce
in SQL, but if it did happen we'd make some dumb decisions.

13 years agoFix buffer overrun in pg_upgrade.
Tom Lane [Tue, 2 Nov 2010 21:31:54 +0000 (17:31 -0400)]
Fix buffer overrun in pg_upgrade.

Problem reported, and cause identified, by Hernan Gonzalez.

13 years agoEnsure an index that uses a whole-row Var still depends on its table.
Tom Lane [Tue, 2 Nov 2010 21:15:13 +0000 (17:15 -0400)]
Ensure an index that uses a whole-row Var still depends on its table.

We failed to record any dependency on the underlying table for an index
declared like "create index i on t (foo(t.*))".  This would create trouble
if the table were dropped without previously dropping the index.  To fix,
simplify some overly-cute code in index_create(), accepting the possibility
that sometimes the whole-table dependency will be redundant.  Also document
this hazard in dependency.c.  Per report from Kevin Grittner.

In passing, prevent a core dump in pg_get_indexdef() if the index's table
can't be found.  I came across this while experimenting with Kevin's
example.  Not sure it's a real issue when the catalogs aren't corrupt, but
might as well be cautious.

Back-patch to all supported versions.

13 years agoBootstrap WAL to begin at segment logid=0 logseg=1 (000000010000000000000001)
Heikki Linnakangas [Tue, 2 Nov 2010 09:23:43 +0000 (11:23 +0200)]
Bootstrap WAL to begin at segment logid=0 logseg=1 (000000010000000000000001)
rather than 0/0, so that we can safely use 0/0 as an invalid value. This is a
more future-proof fix for the corner-case bug in streaming replication that
was fixed yesterday. We had a similar corner-case bug with log/seg 0/0 back in
February as well. Avoiding 0/0 as a valid value should prevent bugs like that
in the future. Per Tom Lane's idea.

Back-patch to 9.0. Since this only affects bootstrapping, it makes no
difference to existing installations. We don't need to worry about the
bug in existing installations, because if you've managed to get past the
initial base backup already, you won't hit the bug in the future either.

13 years agoFix corner-case bug in tracking of latest removed WAL segment during
Heikki Linnakangas [Mon, 1 Nov 2010 07:56:45 +0000 (09:56 +0200)]
Fix corner-case bug in tracking of latest removed WAL segment during
streaming replication. We used log/seg 0/0 to indicate that no WAL segments
have been removed since startup, but 0/0 is a valid value for the very first
WAL segment after initdb. To make that disambiguous, store
(latest removed WAL segment + 1) in the global variable.

Per report from Matt Chesler, also reproduced by Greg Smith.

13 years agoFix plpgsql's handling of "simple" expression evaluation.
Tom Lane [Thu, 28 Oct 2010 17:01:01 +0000 (13:01 -0400)]
Fix plpgsql's handling of "simple" expression evaluation.

In general, expression execution state trees aren't re-entrantly usable,
since functions can store private state information in them.
For efficiency reasons, plpgsql tries to cache and reuse state trees for
"simple" expressions.  It can get away with that most of the time, but it
can fail if the state tree is dirty from a previous failed execution (as
in an example from Alvaro) or is being used recursively (as noted by me).

Fix by tracking whether a state tree is in use, and falling back to the
"non-simple" code path if so.  This results in a pretty considerable speed
hit when the non-simple path is taken, but the available alternatives seem
even more unpleasant because they add overhead in the simple path.  Per
idea from Heikki.

Back-patch to all supported branches.

13 years agoFix long-standing segfault when accept() or one of the calls made right
Heikki Linnakangas [Wed, 27 Oct 2010 17:03:00 +0000 (20:03 +0300)]
Fix long-standing segfault when accept() or one of the calls made right
after accepting a connection fails, and the server is compiled with GSSAPI
support. Report and patch by Alexander V. Chernikov, bug #5731.

13 years agoFix up some oversights in psql's Unicode-escape support.
Tom Lane [Wed, 27 Oct 2010 02:23:16 +0000 (22:23 -0400)]
Fix up some oversights in psql's Unicode-escape support.

Original patch failed to include new exclusive states in a switch that
needed to include them; and also was guilty of very fuzzy thinking
about how to handle error cases.  Per bug #5729 from Alan Choi.

13 years agoNote explicitly that hash indexes are also not replicated because they're not
Heikki Linnakangas [Tue, 26 Oct 2010 19:50:31 +0000 (22:50 +0300)]
Note explicitly that hash indexes are also not replicated because they're not
WAL-logged. Make the notice about the lack of WAL-logging more visible by
making it a <caution>. Also remove the false statement from hot standby
caveats section that hash indexes are not used during hot standby.

13 years agoBefore removing backup_label and irrevocably changing pg_control file, check
Heikki Linnakangas [Tue, 26 Oct 2010 18:15:42 +0000 (21:15 +0300)]
Before removing backup_label and irrevocably changing pg_control file, check
that WAL file containing the checkpoint redo-location can be found. This
avoids making the cluster irrecoverable if the redo location is in an earlie
WAL file than the checkpoint record.

Report, analysis and patch by Jeff Davis, with small changes by me.

13 years agoFix inline_set_returning_function() to preserve the invalItems list properly.
Tom Lane [Mon, 25 Oct 2010 17:04:42 +0000 (13:04 -0400)]
Fix inline_set_returning_function() to preserve the invalItems list properly.

This avoids a possible crash when inlining a SRF whose argument list
contains a reference to an inline-able user function.  The crash is quite
reproducible with CLOBBER_FREED_MEMORY enabled, but would be less certain
in a production build.  Problem introduced in 9.0 by the named-arguments
patch, which requires invoking eval_const_expressions() before we can try
to inline a SRF.  Per report from Brendan Jurd.

13 years agoAdd semicolon, missed in previous patch. And update the keyword list in
Heikki Linnakangas [Fri, 22 Oct 2010 15:38:31 +0000 (18:38 +0300)]
Add semicolon, missed in previous patch. And update the keyword list in
the docs to reflect that OFF is now unreserved. Spotted by Tom Lane.

13 years agoMake OFF keyword unreserved. It's not hard to imagine wanting to use 'off'
Heikki Linnakangas [Fri, 22 Oct 2010 14:37:38 +0000 (17:37 +0300)]
Make OFF keyword unreserved. It's not hard to imagine wanting to use 'off'
as a variable or column name, and it's not reserved in recent versions of
the SQL spec either. This became particularly annoying in 9.0, before that
PL/pgSQL replaced variable names in queries with parameter markers, so
it was possible to use OFF and many other backend parser keywords as
variable names. Because of that, backpatch to 9.0.

13 years agoRemove obsolete comment, per Josh Kupershmidt.
Tom Lane [Wed, 20 Oct 2010 21:05:15 +0000 (17:05 -0400)]
Remove obsolete comment, per Josh Kupershmidt.

13 years agoIf pk is NULL, the backend would segfault when accessing ->algo and the
Heikki Linnakangas [Wed, 20 Oct 2010 19:20:33 +0000 (22:20 +0300)]
If pk is NULL, the backend would segfault when accessing ->algo and the
following NULL check was never reached.

This problem was found by Coccinelle (null_ref.cocci from coccicheck).

Marti Raudsepp

13 years agoDon't try to fetch database name when SetTransactionIdLimit() is executed
Tom Lane [Wed, 20 Oct 2010 16:48:57 +0000 (12:48 -0400)]
Don't try to fetch database name when SetTransactionIdLimit() is executed
outside a transaction.

This repairs brain fade in my patch of 2009-08-30: the reason we had been
storing oldest-database name, not OID, in ShmemVariableCache was of course
to avoid having to do a catalog lookup at times when it might be unsafe.

This error explains why Aleksandr Dushein is having trouble getting out of
an XID wraparound state in bug #5718, though not how he got into that state
in the first place.  I suspect pg_upgrade is at fault there.

13 years agoFix ecpg test building process to not generate *.dSYM junk on Macs.
Tom Lane [Wed, 20 Oct 2010 04:55:03 +0000 (00:55 -0400)]
Fix ecpg test building process to not generate *.dSYM junk on Macs.

The trick is to not try to build executables directly from .c files,
but to always build the intermediate .o files.  For obscure reasons,
Darwin's version of gcc will leave debug cruft behind in the first
case but not the second.  Per complaint from Robert Haas.

13 years agoUpdate storage.sgml to describe the 9.0 tablespace directory layout.
Tom Lane [Wed, 20 Oct 2010 01:53:08 +0000 (21:53 -0400)]
Update storage.sgml to describe the 9.0 tablespace directory layout.

13 years agoFix incorrect generation of whole-row variables in planner.
Tom Lane [Tue, 19 Oct 2010 19:08:47 +0000 (15:08 -0400)]
Fix incorrect generation of whole-row variables in planner.

A couple of places in the planner need to generate whole-row Vars, and were
cutting corners by setting vartype = RECORDOID in the Vars, even in cases
where there's an identifiable named composite type for the RTE being
referenced.  While we mostly got away with this, it failed when there was
also a parser-generated whole-row reference to the same RTE, because the
two Vars weren't equal() due to the difference in vartype.  Fix by
providing a subroutine the planner can call to generate whole-row Vars
the same way the parser does.

Per bug #5716 from Andrew Tipton.  Back-patch to 9.0 where one of the bogus
calls was introduced (the other one is new in HEAD).

13 years agoAdd removal of PG_VERSION to optional old cluster deletion script.
Bruce Momjian [Tue, 19 Oct 2010 15:52:44 +0000 (15:52 +0000)]
Add removal of PG_VERSION to optional old cluster deletion script.
Backpatch to 9.0.X.

13 years agoAdd mention of using tools/fsync to test fsync methods. Restructure
Bruce Momjian [Tue, 19 Oct 2010 14:58:03 +0000 (14:58 +0000)]
Add mention of using tools/fsync to test fsync methods. Restructure
recent wal_sync_method doc paragraph to be clearer.

13 years agoIn pg_upgrade, rename macro EXEC_EXT to SHELL_EXT for clarity.
Bruce Momjian [Tue, 19 Oct 2010 02:55:58 +0000 (02:55 +0000)]
In pg_upgrade, rename macro EXEC_EXT to SHELL_EXT for clarity.

Backpatch to 9.0.X.

13 years agoRemove tab from SGML.
Bruce Momjian [Mon, 18 Oct 2010 18:51:28 +0000 (18:51 +0000)]
Remove tab from SGML.

13 years agoDocument the tablespace directory "should" be empty, rather than "must"
Bruce Momjian [Mon, 18 Oct 2010 18:16:45 +0000 (18:16 +0000)]
Document the tablespace directory "should" be empty, rather than "must"
be empty.  Because of binary migration usage, it might not be empty.

13 years agoFix msvc build for localized versions of Visual C++
Magnus Hagander [Sun, 17 Oct 2010 14:36:54 +0000 (16:36 +0200)]
Fix msvc build for localized versions of Visual C++

Look only at the non-localized part of the output from "vcbuild /?",
which is used to determine the version of Visual Studio in use. Different
languages seem to localize different amounts of the string, but we assume
the part "Microsoft Visual C++" won't be modified.

13 years agoFix low-risk potential denial of service against RADIUS login.
Magnus Hagander [Fri, 15 Oct 2010 14:59:12 +0000 (16:59 +0200)]
Fix low-risk potential denial of service against RADIUS login.

Corrupt RADIUS responses were treated as errors and not ignored
(which the RFC2865 states they should be). This meant that a
user with unfiltered access to the network of the PostgreSQL
or RADIUS server could send a spoofed RADIUS response
to the PostgreSQL server causing it to reject a valid login,
provided the attacker could also guess (or brute-force) the
correct port number.

Fix is to simply retry the receive in a loop until the timeout
has expired or a valid (signed by the correct RADIUS server)
packet arrives.

Reported by Alan DeKok in bug #5687.

13 years agoCorrect WAL space calculation formula in docs.
Simon Riggs [Fri, 15 Oct 2010 09:19:10 +0000 (10:19 +0100)]
Correct WAL space calculation formula in docs.

Error pointed out by Fujii Masao, though not his patch.

13 years agoAdd pg_user_mappings to the table of system views.
Robert Haas [Thu, 14 Oct 2010 23:12:24 +0000 (19:12 -0400)]
Add pg_user_mappings to the table of system views.

13 years agoImprovements to docs about pg_archive_cleanup and use of archives
Simon Riggs [Thu, 14 Oct 2010 22:23:26 +0000 (23:23 +0100)]
Improvements to docs about pg_archive_cleanup and use of archives

Brendan Jurd

13 years agoComplete the documentation of the USAGE privilege for foreign servers
Peter Eisentraut [Thu, 14 Oct 2010 17:36:42 +0000 (20:36 +0300)]
Complete the documentation of the USAGE privilege for foreign servers

The GRANT reference page failed to mention that the USAGE privilege
allows modifying associated user mappings, although this was already
documented on the CREATE/ALTER/DROP USER MAPPING pages.

13 years agoFix bug in comment of timeline history file.
Simon Riggs [Thu, 14 Oct 2010 18:13:09 +0000 (19:13 +0100)]
Fix bug in comment of timeline history file.

Fujii Masao

13 years agoApplied patch by Itagaki Takahiro to fix incorrect status calculation in
Michael Meskes [Thu, 14 Oct 2010 15:49:01 +0000 (17:49 +0200)]
Applied patch by Itagaki Takahiro to fix incorrect status calculation in
ecpglib. Instead of parsing the statement just as ask the database server.

13 years agoMake title capitalization consistent with surroundings
Peter Eisentraut [Wed, 13 Oct 2010 17:05:16 +0000 (20:05 +0300)]
Make title capitalization consistent with surroundings

13 years agoFix plpython so that it again honors typmod while assigning to tuple fields.
Tom Lane [Tue, 12 Oct 2010 02:16:46 +0000 (22:16 -0400)]
Fix plpython so that it again honors typmod while assigning to tuple fields.

This was broken in 9.0 while improving plpython's conversion behavior for
bytea and boolean.  Per bug report from maizi.

13 years agoFix assorted bugs in GIN's WAL replay logic.
Tom Lane [Mon, 11 Oct 2010 23:04:44 +0000 (19:04 -0400)]
Fix assorted bugs in GIN's WAL replay logic.

The original coding was quite sloppy about handling the case where
XLogReadBuffer fails (because the page has since been deleted).  This
would result in either "bad buffer id: 0" or an Assert failure during
replay, if indeed the page were no longer there.  In a couple of places
it also neglected to check whether the change had already been applied,
which would probably result in corrupted index contents.  I believe that
bug #5703 is an instance of the first problem.  These issues could show up
without replication, but only if you were unfortunate enough to crash
between modification of a GIN index and the next checkpoint.

Back-patch to 8.2, which is as far back as GIN has WAL support.

13 years agoAdjust EXPLAIN documentation, so that it's not unreasonably wide.
Robert Haas [Sat, 9 Oct 2010 02:59:48 +0000 (22:59 -0400)]
Adjust EXPLAIN documentation, so that it's not unreasonably wide.

The new formatting matches what we do for COPY.

Per a complaint from Bruce Momjian.

13 years agoWarn that views can be safely used to hide columns, but not rows.
Robert Haas [Fri, 8 Oct 2010 13:15:17 +0000 (09:15 -0400)]
Warn that views can be safely used to hide columns, but not rows.

13 years agoImprove WAL reliability documentation, and add more cross-references to it.
Robert Haas [Thu, 7 Oct 2010 16:19:03 +0000 (12:19 -0400)]
Improve WAL reliability documentation, and add more cross-references to it.

In particular, we are now more explicit about the fact that you may need
wal_sync_method=fsync_writethrough for crash-safety on some platforms,
including MaxOS X.  There's also now an explicit caution against assuming
that the default setting of wal_sync_method is either crash-safe or best
for performance.

13 years agoMake walsender receive not only Terminate message but also XLogRecPtr one.
MasaoFujii [Thu, 7 Oct 2010 11:32:13 +0000 (20:32 +0900)]
Make walsender receive not only Terminate message but also XLogRecPtr one.

Conflicts:

src/backend/replication/walsender.c

13 years agoDefine new message type 'l' which means the WAL acknowledgment message
MasaoFujii [Wed, 8 Sep 2010 07:54:48 +0000 (16:54 +0900)]
Define new message type 'l' which means the WAL acknowledgment message
from the standby.

13 years agoMake the startup process respond to SIGTERM and SIGHUP immediately.
MasaoFujii [Thu, 7 Oct 2010 11:06:34 +0000 (20:06 +0900)]
Make the startup process respond to SIGTERM and SIGHUP immediately.

To do that we make the signal handlers for those signals wake the
startup process up.

13 years agoChange the document to recent introduction of CopyXLogResponse.
MasaoFujii [Wed, 29 Sep 2010 06:20:09 +0000 (15:20 +0900)]
Change the document to recent introduction of CopyXLogResponse.

13 years agoIntroduce CopyXLogResponse message and make walsender send it as a
MasaoFujii [Wed, 29 Sep 2010 06:06:32 +0000 (15:06 +0900)]
Introduce CopyXLogResponse message and make walsender send it as a
replication starting message instead of CopyOutResponse.

13 years agoAdd interface function 'libpqrcv_send' to allow walreceiver to send messages back...
MasaoFujii [Wed, 8 Sep 2010 07:39:09 +0000 (16:39 +0900)]
Add interface function 'libpqrcv_send' to allow walreceiver to send messages back to the 

13 years agoThe port/pg_latch.c symlink ought to be removed by make distclean.
Tom Lane [Tue, 21 Sep 2010 20:53:25 +0000 (16:53 -0400)]
The port/pg_latch.c symlink ought to be removed by make distclean.

Not sure why these symlinks are removed here and not in the port/
Makefile, but I won't second-guess that choice right now.

13 years agoFix two typos in comments, spotted by Fujii Masao and Thom Brown
Heikki Linnakangas [Wed, 15 Sep 2010 13:58:22 +0000 (13:58 +0000)]
Fix two typos in comments, spotted by Fujii Masao and Thom Brown

13 years agoUse a latch to make startup process wake up and replay immediately when
MasaoFujii [Thu, 7 Oct 2010 10:49:34 +0000 (19:49 +0900)]
Use a latch to make startup process wake up and replay immediately when
new WAL arrives via streaming replication. This reduces the latency, and
also allows us to use a longer polling interval, which is good for energy
efficiency.

We still need to poll to check for the appearance of a trigger file, but
the interval is now 5 seconds (instead of 100ms), like when waiting for
a new WAL segment to appear in WAL archive.

Conflicts:

src/backend/access/transam/xlog.c
src/include/access/xlog.h

13 years agoSimplify Windows implementation of latches. There's no need to keep a
Heikki Linnakangas [Wed, 15 Sep 2010 10:06:21 +0000 (10:06 +0000)]
Simplify Windows implementation of latches. There's no need to keep a
dynamic pool of event handles, we can permanently assign one for each
shared latch. Thanks to that, we no longer need a separate shared memory
block for latches, and we don't need to know in advance how many shared
latches there is, so you no longer need to remember to update
NumSharedLatches when you introduce a new latch to the system.

13 years agoDon't call OwnLatch while holding a spinlock. OwnLatch can elog() under
Heikki Linnakangas [Wed, 15 Sep 2010 06:51:19 +0000 (06:51 +0000)]
Don't call OwnLatch while holding a spinlock. OwnLatch can elog() under
some "can't happen" scenarios, and spinlocks should only be held for
a few instructions anyway. As pointed out by Fujii Masao.

13 years agoOops, the timeout argument to WaitLatchOrSocket is in microseconds, not
Heikki Linnakangas [Tue, 14 Sep 2010 13:35:14 +0000 (13:35 +0000)]
Oops, the timeout argument to WaitLatchOrSocket is in microseconds, not
milliseconds.

13 years agoAdd a comment noting that the owner_pid test in OwnLatch is just a sanity
Heikki Linnakangas [Mon, 13 Sep 2010 18:01:20 +0000 (18:01 +0000)]
Add a comment noting that the owner_pid test in OwnLatch is just a sanity
check, per request by Jeff Davis.

13 years agoAdd missing #includes, needed on some platforms. This should make
Heikki Linnakangas [Sat, 11 Sep 2010 16:26:04 +0000 (16:26 +0000)]
Add missing #includes, needed on some platforms. This should make
the unixware buildfarm animals happy again.

13 years agoIntroduce latches. A latch is a boolean variable, with the capability to
MasaoFujii [Thu, 7 Oct 2010 10:43:58 +0000 (19:43 +0900)]
Introduce latches. A latch is a boolean variable, with the capability to
wait until it is set. Latches can be used to reliably wait until a signal
arrives, which is hard otherwise because signals don't interrupt select()
on some platforms, and even when they do, there's race conditions.

On Unix, latches use the so called self-pipe trick under the covers to
implement the sleep until the latch is set, without race conditions. On
Windows, Windows events are used.

Use the new latch abstraction to sleep in walsender, so that as soon as
a transaction finishes, walsender is woken up to immediately send the WAL
to the standby. This reduces the latency between master and standby, which
is good.

Preliminary work by Fujii Masao. The latch implementation is by me, with
helpful comments from many people.

13 years agoIn postgresql.conf.sample, use on/off rather than true/false.
Robert Haas [Tue, 27 Jul 2010 16:06:53 +0000 (16:06 +0000)]
In postgresql.conf.sample, use on/off rather than true/false.

We used to be consistent about this, but my recent patch to add a
restart_after_crash GUC failed to follow the existing convention.

Report and patch from Fujii Masao.

13 years agoAdd restart_after_crash GUC.
MasaoFujii [Thu, 7 Oct 2010 10:15:43 +0000 (19:15 +0900)]
Add restart_after_crash GUC.

Normally, we automatically restart after a backend crash, but in some
cases when PostgreSQL is invoked by clusterware it may be desirable to
suppress this behavior, so we provide an option which does this.
Since no existing GUC group quite fits, create a new group called
"error handling options" for this and the previously undocumented GUC
exit_on_error, which is now documented.

Review by Fujii Masao.

Conflicts:

doc/src/sgml/config.sgml
src/backend/postmaster/postmaster.c
src/backend/utils/misc/guc.c

13 years agoCorrect docs for behaviour of ALTER DATABASE .. RENAME during Hot Standby.
Simon Riggs [Tue, 5 Oct 2010 23:20:54 +0000 (00:20 +0100)]
Correct docs for behaviour of ALTER DATABASE .. RENAME during Hot Standby.
Actual behaviour did not match documented behaviour and we have agreed
that it should be the docs that change.

Spotted by Bernd Helmle

13 years agoUndo some poorly-thought-out "proofreading improvements".
Tom Lane [Tue, 5 Oct 2010 22:48:20 +0000 (18:48 -0400)]
Undo some poorly-thought-out "proofreading improvements".
Per Tatsuhito Kasahara.

13 years agoBehave correctly if INSERT ... VALUES is decorated with additional clauses.
Tom Lane [Sun, 3 Oct 2010 00:02:33 +0000 (20:02 -0400)]
Behave correctly if INSERT ... VALUES is decorated with additional clauses.

In versions 8.2 and up, the grammar allows attaching ORDER BY, LIMIT,
FOR UPDATE, or WITH to VALUES, and hence to INSERT ... VALUES.  But the
special-case code for VALUES in transformInsertStmt() wasn't expecting any
of those, and just ignored them, leading to unexpected results.  Rather
than complicate the special-case path, just ensure that the presence of any
of those clauses makes us treat the query as if it had a general SELECT.
Per report from Hitoshi Harada.

13 years agoRemove excess argument to open(2).
Tom Lane [Sat, 2 Oct 2010 22:40:28 +0000 (18:40 -0400)]
Remove excess argument to open(2).

Many compilers don't complain about this, but some do, and it's certainly
wrong.  Back-patch to 8.4 where the error was introduced.

Mark Kirkwood

13 years agoThrow an appropriate error if ALTER COLUMN TYPE finds a dependent trigger.
Tom Lane [Sat, 2 Oct 2010 22:21:41 +0000 (18:21 -0400)]
Throw an appropriate error if ALTER COLUMN TYPE finds a dependent trigger.

Actually making this case work, if the column is used in the trigger's
WHEN condition, will take some new code that probably isn't appropriate
to back-patch.  For now, just throw a FEATURE_NOT_SUPPORTED error rather
than allowing control to reach the "unexpected object" case.  Per bug #5688
from Daniel Grace.  Back-patch to 9.0 where the possibility of such a
dependency was introduced.

13 years agoFix back-branch breakage from ill-advised last-minute commit. REL9_0_1
Tom Lane [Fri, 1 Oct 2010 14:25:44 +0000 (10:25 -0400)]
Fix back-branch breakage from ill-advised last-minute commit.

13 years agoTag 9.0.1
Marc G. Fournier [Fri, 1 Oct 2010 13:28:42 +0000 (10:28 -0300)]
Tag 9.0.1

13 years agoUse a separate interpreter for each calling SQL userid in plperl and pltcl.
Tom Lane [Thu, 30 Sep 2010 21:19:44 +0000 (17:19 -0400)]
Use a separate interpreter for each calling SQL userid in plperl and pltcl.

There are numerous methods by which a Perl or Tcl function can subvert
the behavior of another such function executed later; for example, by
redefining standard functions or operators called by the target function.
If the target function is SECURITY DEFINER, or is called by such a
function, this means that any ordinary SQL user with Perl or Tcl language
usage rights can do essentially anything with the privileges of the target
function's owner.

To close this security hole, create a separate Perl or Tcl interpreter for
each SQL userid under which plperl or pltcl functions are executed within
a session.  However, all plperlu or pltclu functions run within a session
still share a single interpreter, since they all execute at the trust
level of a database superuser anyway.

Note: this change results in a functionality loss when libperl has been
built without the "multiplicity" option: it's no longer possible to call
plperl functions under different userids in one session, since such a
libperl can't support multiple interpreters in one process.  However, such
a libperl already failed to support concurrent use of plperl and plperlu,
so it's likely that few people use such versions with Postgres.

Security: CVE-2010-3433