users/andresfreund/postgres.git
12 years agobdr: sequences: indent bdr/0.4
Andres Freund [Wed, 29 May 2013 00:34:47 +0000 (02:34 +0200)]
bdr: sequences: indent

12 years agobdr: sequences: Do all votes within a single transaction
Andres Freund [Tue, 28 May 2013 22:54:26 +0000 (00:54 +0200)]
bdr: sequences: Do all votes within a single transaction

12 years agobdr: sequences: mergme: Qualify sequences for voting
Andres Freund [Tue, 28 May 2013 22:53:27 +0000 (00:53 +0200)]
bdr: sequences: mergme: Qualify sequences for voting

This lead sequence chunks needing to be unique across all sequences instead of
just one.

12 years agobdr: sequence: mergme: Fix off-by-one in definition of sufficient nodes for election
Andres Freund [Tue, 28 May 2013 02:45:21 +0000 (04:45 +0200)]
bdr: sequence: mergme: Fix off-by-one in definition of sufficient nodes for election

12 years agobdr: mergme: Stat module improvements around increasing the number of nodes
Andres Freund [Tue, 28 May 2013 02:44:46 +0000 (04:44 +0200)]
bdr: mergme: Stat module improvements around increasing the number of nodes

12 years agobdr: sequences: mergme: count properly when there are no votes yet
Andres Freund [Tue, 28 May 2013 01:30:42 +0000 (03:30 +0200)]
bdr: sequences: mergme: count properly when there are no votes yet

12 years agowal_decoding: mergme: fix typo introduced in decode.c refactoring
Andres Freund [Mon, 27 May 2013 23:12:06 +0000 (01:12 +0200)]
wal_decoding: mergme: fix typo introduced in decode.c refactoring

12 years agobdr: mergme: Fix typo
Abhijit Menon-Sen [Mon, 20 May 2013 03:44:11 +0000 (09:14 +0530)]
bdr: mergme: Fix typo

12 years agobdr: mergme: Call bdr_count_disconnect() for connection errors in bdr_main
Abhijit Menon-Sen [Sat, 18 May 2013 18:48:15 +0000 (00:18 +0530)]
bdr: mergme: Call bdr_count_disconnect() for connection errors in bdr_main

12 years agobdr: mergme: bdr_count bug: version was written as hardcoded 1
Alvaro Herrera [Mon, 27 May 2013 21:26:26 +0000 (17:26 -0400)]
bdr: mergme: bdr_count bug: version was written as hardcoded 1

12 years agobdr: mergme: minor tweaks in contrib/bdr
Alvaro Herrera [Mon, 27 May 2013 20:17:39 +0000 (16:17 -0400)]
bdr: mergme: minor tweaks in contrib/bdr

12 years agobdr: mergme: Don't leak a file descriptor in bdr_count_serialize
Alvaro Herrera [Fri, 24 May 2013 18:39:38 +0000 (14:39 -0400)]
bdr: mergme: Don't leak a file descriptor in bdr_count_serialize

12 years agowal_decoding: mergme: Desultory code review in decode.c
Alvaro Herrera [Thu, 23 May 2013 22:29:20 +0000 (18:29 -0400)]
wal_decoding: mergme: Desultory code review in decode.c

Mostly style fixes.  A large function was split.

12 years agobdr: mergme: Reply to feedback messages
Andres Freund [Mon, 27 May 2013 22:43:45 +0000 (00:43 +0200)]
bdr: mergme: Reply to feedback messages

Alvaro

12 years agowal_decoding: mergme: timeout handling
Alvaro Herrera [Thu, 23 May 2013 15:40:45 +0000 (11:40 -0400)]
wal_decoding: mergme: timeout handling

12 years agowal_decoding: mergme: Cleanups from Alvaro
Andres Freund [Mon, 27 May 2013 22:21:09 +0000 (00:21 +0200)]
wal_decoding: mergme: Cleanups from Alvaro

12 years agowal_decodign: mergme: Cleanups from Alvaro
Andres Freund [Mon, 27 May 2013 22:20:51 +0000 (00:20 +0200)]
wal_decodign: mergme: Cleanups from Alvaro

12 years agowal_decoding: mergme: implement "caught-up" logic for LLSR
Alvaro Herrera [Fri, 17 May 2013 17:40:33 +0000 (13:40 -0400)]
wal_decoding: mergme: implement "caught-up" logic for LLSR

This lets walsender terminate nicely when a signal from postmaster
arrives.

12 years agobdr: mergme: fix typo
Alvaro Herrera [Fri, 17 May 2013 15:00:48 +0000 (11:00 -0400)]
bdr: mergme: fix typo

12 years agobdr: sequences: mergme: Support nextval()
Andres Freund [Mon, 27 May 2013 08:03:23 +0000 (10:03 +0200)]
bdr: sequences: mergme: Support nextval()

12 years agowal_decoding: mergme: demote some messages
Andres Freund [Mon, 27 May 2013 08:03:04 +0000 (10:03 +0200)]
wal_decoding: mergme: demote some messages

12 years agoseqam: mergme: export some functions
Andres Freund [Mon, 27 May 2013 08:02:40 +0000 (10:02 +0200)]
seqam: mergme: export some functions

12 years agobdr: mergme: bdr_seq.c needs to be added to the windows buildsystem.
Andres Freund [Tue, 21 May 2013 05:24:03 +0000 (07:24 +0200)]
bdr: mergme: bdr_seq.c needs to be added to the windows buildsystem.

12 years agobdr-sequence: mergme: use consistent order of inserts tablewise
Andres Freund [Tue, 21 May 2013 03:01:20 +0000 (05:01 +0200)]
bdr-sequence: mergme: use consistent order of inserts tablewise

This removes intermittent (detected/resolved) deadlocks between the sequence
manager and logical replication.

12 years agoseqam: mergme: remove superflous statement
Andres Freund [Tue, 21 May 2013 03:00:42 +0000 (05:00 +0200)]
seqam: mergme: remove superflous statement

12 years agobdr-sequences 0.1
Andres Freund [Tue, 21 May 2013 02:15:48 +0000 (04:15 +0200)]
bdr-sequences 0.1

12 years agoseqam 0.2
Andres Freund [Mon, 20 May 2013 14:18:35 +0000 (16:18 +0200)]
seqam 0.2

12 years agotmp
Andres Freund [Mon, 20 May 2013 06:50:57 +0000 (08:50 +0200)]
tmp

12 years agobdr: mergme: different name for the worker variable in _PG_init
Andres Freund [Sun, 19 May 2013 15:44:36 +0000 (17:44 +0200)]
bdr: mergme: different name for the worker variable in _PG_init

12 years agobdr: mergme: better background worker name
Andres Freund [Sun, 19 May 2013 15:41:56 +0000 (17:41 +0200)]
bdr: mergme: better background worker name

12 years agobdr: isolationtester: Isolationtester with multi-server support
Abhijit Menon-Sen [Mon, 13 May 2013 09:13:41 +0000 (14:43 +0530)]
bdr: isolationtester: Isolationtester with multi-server support

The spec file can now start with declarations like this:

    conninfo "cname1" "port=NNNN dbname=XYZ"
    conninfo "cname2" "port=MMMM dbname=PQR"

And sessions may include connection declarations like this:

    session "s1"
    connection "cname1"

Both are optional. If no connection information is explicitly specified,
then the earlier behaviour (use conninfo from commandline or fall back
to "dbname=postgres") is retained.

If connection information is specified, we open one "global" connection
per conninfo (for lock checking) and one connection per session. Setup
SQL is executed only on conns[0], as before (but perhaps it would help
to execute it on all until DDL replication is implemented?).

Includes the rudimentary tests from before, including some failing ones.

12 years agobdr: bdr plugin
Andres Freund [Fri, 17 May 2013 16:15:37 +0000 (18:15 +0200)]
bdr: bdr plugin

Andres Freund, Alvaro Herrera, Abhijit Menon-Sen

12 years agobdr: Add database oid to IDENTIFY_SYSTEM
Andres Freund [Fri, 3 May 2013 14:53:58 +0000 (16:53 +0200)]
bdr: Add database oid to IDENTIFY_SYSTEM

Adjust all IDENTIFY_SYSTEM callers

12 years agowal_decoding: reorderbuffer: Track original commit timestamp of a transaction
Andres Freund [Fri, 17 May 2013 16:11:44 +0000 (18:11 +0200)]
wal_decoding: reorderbuffer: Track original commit timestamp of a transaction

12 years agobdr: Introduce "replication_identifiers" to keep track of remote nodes
Andres Freund [Fri, 22 Feb 2013 16:43:27 +0000 (17:43 +0100)]
bdr: Introduce "replication_identifiers" to keep track of remote nodes

Replication identifiers can be used to track & lookup remote nodes identified
via (sysid, tlid, remote_dbid, local_dbid, name) and map that tuple to a local
uint16.
Keyed by that replication identifier the remote lsn and the local lsn is
tracked in a crash safe manner.

Support for tracking that via output plugins is added as well.

Needs a catversion bump.

12 years agocommitts: mergme: add comment about wal logging committs in RecordTransactionCommit
Andres Freund [Fri, 17 May 2013 15:07:32 +0000 (17:07 +0200)]
committs: mergme: add comment about wal logging committs in RecordTransactionCommit

12 years agocommitts: mergme: Remove unused 'recptr' variables
Andres Freund [Fri, 17 May 2013 15:07:05 +0000 (17:07 +0200)]
committs: mergme: Remove unused 'recptr' variables

12 years agocommitts: Store transaction commit time
Alvaro Herrera [Mon, 11 Mar 2013 14:27:29 +0000 (11:27 -0300)]
committs: Store transaction commit time

Conflicts:
src/backend/utils/misc/postgresql.conf.sample

12 years agobdr: Allow repeatedly qualified IDs in postgresql.conf and allow them to start with...
Andres Freund [Mon, 25 Feb 2013 21:02:12 +0000 (22:02 +0100)]
bdr: Allow repeatedly qualified IDs in postgresql.conf and allow them to start with numbers from the second ID

12 years agowal_decoding: design document v2.3 and snapshot building design doc v0.2
Andres Freund [Thu, 20 Sep 2012 10:38:15 +0000 (12:38 +0200)]
wal_decoding: design document v2.3 and snapshot building design doc v0.2

12 years agowal_decoding: test_logical_decoding: Add extension for easier testing of logical...
Abhijit Menon-Sen [Fri, 11 Jan 2013 09:06:48 +0000 (14:36 +0530)]
wal_decoding: test_logical_decoding: Add extension for easier testing of logical decoding

This extension provides three functions for manipulating replication slots:
* init_logical_replication - initiate a replication slot and wait for consistent state
* start_logical_replication - return all changes since the last call up to now, without blocking
* free_logical_replication - free the logical slot again

Those are pretty direct synonyms for the replication connection commands.

Due to questions about how to integrate logical replication tests this module
also contains the current tests of logical replication itself.

Author: Abhijit Menon-Sen

12 years agowal_decoding: pg_receivellog: Introduce pg_receivexlog equivalent for logical changes
Andres Freund [Sun, 11 Nov 2012 12:07:51 +0000 (13:07 +0100)]
wal_decoding: pg_receivellog: Introduce pg_receivexlog equivalent for logical changes

12 years agowal_decoding: test_decoding: Add a simple decoding module in contrib
Andres Freund [Sun, 11 Nov 2012 12:01:52 +0000 (13:01 +0100)]
wal_decoding: test_decoding: Add a simple decoding module in contrib

This is mostly useful for testing, demonstration and documentation purposes.

12 years agowal_decoding: Introduce wal decoding via catalog timetravel
Andres Freund [Thu, 5 Apr 2012 09:07:33 +0000 (11:07 +0200)]
wal_decoding: Introduce wal decoding via catalog timetravel

This introduces several things:
* 'reorderbuffer' module which reassembles transactions from a stream of interspersed changes
* 'snapbuilder' which builds catalog snapshots so that tuples from wal can be understood
* logging more data into wal to facilitate logical decoding
* wal decoding into an reorderbuffer
* shared library output plugins with 5 callbacks
 * init
 * begin
 * change
 * commit
* walsender infrastructur to stream out changes and to keep the global xmin low enough
 * INIT_LOGICAL_REPLICATION $plugin; waits till a consistent snapshot is built and returns
   * initial LSN
   * replication slot identifier
   * id of a pg_export() style snapshot
 * START_LOGICAL_REPLICATION $id $lsn; streams out changes
 * uses named output plugins for output specification

Todo:
* better integrated testing infrastructure
* more frequent lowering of xmins
* more docs about the internals
* support for user declared catalog tables

Lowlevel:
* REINDEX/VACUUM FULL support for timetravel txns
* resource owner handling is suboptimal
* invalidations from uninteresting transactions (e.g. from other databases, old ones)
  need to be processed anyway
* error handling in walsender is suboptimal
* walsender slots need to be marked as catchup
* pg_receivellog needs to send a reply immediately when postgres is shutting down

Input, Testing and Review by:
Heikki Linnakangas
Kevin Grittner
Michael Paquier
Abhijit Menon-Sen
Peter Gheogegan
Robert Haas
Simon Riggs
Steve Singer

Code By:
Andres Freund

With Contributions by:
Abhijit Menon-Sen
Craig Ringer
Alvaro Herrera

12 years agowal_decoding: Add information about a tables primary key to struct RelationData
Andres Freund [Mon, 14 Jan 2013 11:16:54 +0000 (12:16 +0100)]
wal_decoding: Add information about a tables primary key to struct RelationData

'rd_primary' now contains the Oid of an index over uniquely identifying
columns. Several types of indexes are interesting and are collected in that
order:
* Primary Key
* oid index
* the first (OID order) unique, immediate, non-partial and
  non-expression index over one or more NOT NULL'ed columns

To gather rd_primary value RelationGetIndexList() needs to have been called.

This is helpful because for logical replication we frequently - on the sending
and receiving side - need to lookup that index and RelationGetIndexList already
gathers all the necessary information.

This could be used to replace tablecmd.c's transformFkeyGetPrimaryKey, but
would change the meaning of that, so it seems to require additional discussion.

12 years agowal_decoding: copydir: make fsync_fname public
Andres Freund [Wed, 9 Jan 2013 16:36:20 +0000 (17:36 +0100)]
wal_decoding: copydir: make fsync_fname public

This probably should be somewhere else, its a generally useful function, not
really related to copying directories. fd.[ch]?

12 years agowal_decoding: Log xl_running_xact's at a higher frequency than checkpoints are done
Andres Freund [Mon, 10 Dec 2012 11:08:30 +0000 (12:08 +0100)]
wal_decoding: Log xl_running_xact's at a higher frequency than checkpoints are done

Do so in the background writer which seems to be the best choice as its
regularly running and shouldn't be busy for too long without getting back into
its main loop.

Also mark xl_standby records as being relevant for async commit so the wal
writer writes them out soonish.

This might also be beneficial for HS as it would make it faster to hit a spot
where no (old) transactions are running anymroe.

12 years agowal_decoding: Add alreadyLocked parameter to GetOldestXminNoLock
Andres Freund [Thu, 13 Dec 2012 19:47:57 +0000 (20:47 +0100)]
wal_decoding: Add alreadyLocked parameter to GetOldestXminNoLock

This is useful because it allows to compute the current OldestXmin while
already holding the procarray lock which enables setting the own xmin horizon
safely.

12 years agowal_decoding: Allow walsender's to connect to a specific database
Andres Freund [Tue, 13 Nov 2012 11:54:36 +0000 (12:54 +0100)]
wal_decoding: Allow walsender's to connect to a specific database

Currently the decision whether to connect to a database or not is made by
checking whether the passed "dbname" parameter is "replication". Unfortunately
this makes it impossible to connect a to a database named replication...

This is useful for future walsender commands which need database interaction.

12 years agowal_decoding: Adjust all *Satisfies routines to take a HeapTuple instead of a HeapTup...
Andres Freund [Mon, 12 Nov 2012 12:39:52 +0000 (13:39 +0100)]
wal_decoding: Adjust all *Satisfies routines to take a HeapTuple instead of a HeapTupleHeader

For the regular satisfies routines this is needed in prepareation of logical
decoding. I changed the non-regular ones for consistency as well.

The naming between htup, tuple and similar is rather confused, I could not find
any consistent naming anywhere.

This is preparatory work for the logical decoding feature which needs to be
able to get to a valid relfilenode from when checking the visibility of a
tuple.

12 years agowal_decoding: Introduce InvalidCommandId and declare that to be the new maximum for...
Andres Freund [Tue, 13 Nov 2012 11:18:07 +0000 (12:18 +0100)]
wal_decoding: Introduce InvalidCommandId and declare that to be the new maximum for CommandCounterIncrement

This is useful to be able to represent a CommandId thats invalid. There was no
such value before.

This decreases the possible number of subtransactions by one which seems
unproblematic. Its also not a problem for pg_upgrade because cmin/cmax are
never looked at outside the context of their own transaction (spare timetravel
access, but thats new anyway).

12 years agowal_decoding: Add pg_relation_by_filenode to lookup up a relation by (tablespace...
Andres Freund [Sun, 16 Sep 2012 21:53:23 +0000 (23:53 +0200)]
wal_decoding: Add pg_relation_by_filenode to lookup up a relation by (tablespace, filenode)

This requires the previously added RELFILENODE syscache and the added
RelationMapFilenodeToOid function added in previous two commits.

12 years agowal_decoding: Add RelationMapFilenodeToOid function to relmapper.c
Andres Freund [Sun, 16 Sep 2012 21:51:08 +0000 (23:51 +0200)]
wal_decoding: Add RelationMapFilenodeToOid function to relmapper.c

This function maps (reltablespace, relfilenode) to the table oid and thus acts
as a reverse of RelationMapOidToFilenode.

12 years agowal_decoding: Add a new RELFILENODE syscache to fetch a pg_class entry via (reltables...
Andres Freund [Thu, 5 Apr 2012 09:09:59 +0000 (11:09 +0200)]
wal_decoding: Add a new RELFILENODE syscache to fetch a pg_class entry via (reltablespace, relfilenode)

This cache is theoretically problematic because formally indexes used by
syscaches needs to be unique, this one is not. This is "just" because of
0/InvalidOid are stored in pg_class.relfilenode for nailed/shared catalog
relations. This syscache will never be queried for InvalidOid relfilenodes
however so it seems to be safe even if it bends the rules somewhat.

It might be nicer to add infrastructure to do this properly, like using a
partial index, its not clear what the best way to do this is though and the
benefit very well might not be worth the overhead.

Needs a CATVERSION bump.

12 years agowal_decoding: Add pg_xlog_wait_remote_{apply,receive} functions
Abhijit Menon-Sen [Thu, 16 May 2013 16:55:56 +0000 (22:25 +0530)]
wal_decoding: Add pg_xlog_wait_remote_{apply,receive} functions

We want to use these in isolationtester tests, but they're more
generally useful for "inter-node synchronisation".

12 years agoAdd support for in-memory out-of-line stored toast data
Andres Freund [Sun, 17 Feb 2013 00:38:17 +0000 (01:38 +0100)]
Add support for in-memory out-of-line stored toast data

For some use-cases like logical decoding of wal or avoidance of repeated
detoasting of toast tuples it is useful to represent varlenas that are stored
in memory but outside of a HeapTuple. E.g. because it is impossible to allocate
a memory chunk for the whole tuple at once or because the overhead of repeated
detoasting from disk is noticeable.

For that support "indirect" toast tuples which point to another 'struct
varlena' in memory. That referenced tuple can be short, compressed or normal.

As there are no further flag bits available to discern such an indirection from
the other forms inside the original Datum we reuse the VARATT_IS_EXTERNAL
representation for this which apt because they are also
out-of-line. Unfortunately only varatt_1b_e.va_length is available to discern
toast and indirection toast tuple, so they must be different for both. A
StaticAssertStm to make sure of that is included.

12 years agoFix crash when trying to display a NOTIFY rule action.
Tom Lane [Thu, 16 May 2013 20:47:26 +0000 (16:47 -0400)]
Fix crash when trying to display a NOTIFY rule action.

Fixes oversight in commit 2ffa740be9d96a3743ecb7e42391c53d0760c65a.
Per report from Josh Kupershmidt.

I think we've broken this case before, so let's add a regression test
this time.

12 years agoFix fd.c to preserve errno where needed.
Tom Lane [Thu, 16 May 2013 19:04:31 +0000 (15:04 -0400)]
Fix fd.c to preserve errno where needed.

PathNameOpenFile failed to ensure that the correct value of errno was
returned to its caller after a failure (because it incorrectly supposed
that free() can never change errno).  In some cases this would result
in a user-visible failure because an expected ENOENT errno was replaced
with something else.  Bogus EINVAL failures have been observed on OS X,
for example.

There were also a couple of places that could mangle an important value
of errno if FDDEBUG was defined.  While the usefulness of that debug
support is highly debatable, we might as well make it safe to use,
so add errno save/restore logic to the DO_DB macro.

Per bug #8167 from Nelson Minar, diagnosed by RhodiumToad.
Back-patch to all supported branches.

12 years agoFix some uses of "the quick brown fox".
Tom Lane [Thu, 16 May 2013 16:30:41 +0000 (12:30 -0400)]
Fix some uses of "the quick brown fox".

If we're going to quote a well-known pangram, we should quote it
accurately.  Per gripe from Thom Brown.

12 years agoAllow CREATE FOREIGN TABLE to include SERIAL columns.
Tom Lane [Wed, 15 May 2013 23:03:29 +0000 (19:03 -0400)]
Allow CREATE FOREIGN TABLE to include SERIAL columns.

The behavior is that the required sequence is created locally, which is
appropriate because the default expression will be evaluated locally.
Per gripe from Brad Nicholson that this case was refused with a confusing
error message.  We could have improved the error message but it seems
better to just allow the case.

Also, remove ALTER TABLE's arbitrary prohibition against being applied to
foreign tables, which was pretty inconsistent considering we allow it for
views, sequences, and other relation types that aren't even called tables.
This is needed to avoid breaking pg_dump, which sometimes emits column
defaults using separate ALTER TABLE commands.  (I think this can happen
even when the default is not associated with a sequence, so that was a
pre-existing bug once we allowed column defaults for foreign tables.)

12 years agodoc: Add \dm command to psql man page
Peter Eisentraut [Wed, 15 May 2013 01:12:34 +0000 (21:12 -0400)]
doc: Add \dm command to psql man page

12 years agodoc: Fix some whitespace issues in the man pages
Peter Eisentraut [Tue, 14 May 2013 01:59:39 +0000 (21:59 -0400)]
doc: Fix some whitespace issues in the man pages

12 years agopg_upgrade: Replace tabs in output string constants by spaces
Peter Eisentraut [Tue, 14 May 2013 01:42:19 +0000 (21:42 -0400)]
pg_upgrade: Replace tabs in output string constants by spaces

12 years agodoc: Fix order of options on pgbench man page
Peter Eisentraut [Tue, 14 May 2013 01:37:01 +0000 (21:37 -0400)]
doc: Fix order of options on pgbench man page

12 years agoFix handling of OID wraparound while in standalone mode.
Tom Lane [Mon, 13 May 2013 19:40:16 +0000 (15:40 -0400)]
Fix handling of OID wraparound while in standalone mode.

If OID wraparound should occur while in standalone mode (unlikely but
possible), we want to advance the counter to FirstNormalObjectId not
FirstBootstrapObjectId.  Otherwise, user objects might be created with OIDs
in the system-reserved range.  That isn't immediately harmful but it poses
a risk of conflicts during future pg_upgrade operations.

Noted by Andres Freund.  Back-patch to all supported branches, since all of
them are supported sources for pg_upgrade operations.

12 years agoFix handling of strict non-set functions with NULLs in set-valued inputs.
Tom Lane [Sun, 12 May 2013 17:08:12 +0000 (13:08 -0400)]
Fix handling of strict non-set functions with NULLs in set-valued inputs.

In a construct like "select plain_function(set_returning_function(...))",
the plain function is applied to each output row of the SRF successively.
If some of the SRF outputs are NULL, and the plain function is strict,
you'd expect to get NULL results for such rows ... but what actually
happened was that such rows were omitted entirely from the result set.
This was due to confusion of this case with what should happen for nested
set-returning functions; a strict SRF is indeed supposed to yield an empty
set for null input.  Per bug #8150 from Erwin Brandstetter.

Although this has been broken forever, we're not back-patching because
of the possibility that some apps out there expect the incorrect behavior.
This change should be listed as a possible incompatibility in the 9.3
release notes.

12 years agopgbench: Fix order of options in --help output
Peter Eisentraut [Sun, 12 May 2013 01:57:54 +0000 (21:57 -0400)]
pgbench: Fix order of options in --help output

12 years agopg_xlogdump: Improve --help output
Peter Eisentraut [Sun, 12 May 2013 01:55:37 +0000 (21:55 -0400)]
pg_xlogdump: Improve --help output

12 years agoFix to_number() to correctly ignore thousands separator when it's '.'.
Tom Lane [Sat, 11 May 2013 20:35:03 +0000 (16:35 -0400)]
Fix to_number() to correctly ignore thousands separator when it's '.'.

The existing code in NUM_numpart_from_char has hard-wired logic to treat
'.' as decimal point, even when we're using a locale-aware format string
and the locale says that '.' is the thousands separator.  This results in
clearly wrong answers in FM mode (where we must be able to identify the
decimal point location), as per bug report from Patryk Kordylewski.

Since the initialization code in NUM_prepare_locale already sets up
Np->decimal as either the locale decimal-point string or "." depending
on which decimal-point format code was used, there's really no need to
have any extra logic at all in NUM_numpart_from_char: we only need to
test for a match to Np->decimal.

(Note: AFAICS there's nothing in here that explicitly checks for thousands
separators --- rather, any unmatched character is silently skipped over.
That's pretty bogus IMO but it's not the issue being complained of.)

This is a longstanding bug, but it's possible that some existing apps
are depending on '.' being recognized as decimal point even when using
a D format code.  Hence, no back-patch.  We should probably list this
as a potential incompatibility in the 9.3 release notes.

12 years agoFix buildfarm incompatibility in updated pg_upgrade test script.
Tom Lane [Sat, 11 May 2013 20:14:19 +0000 (16:14 -0400)]
Fix buildfarm incompatibility in updated pg_upgrade test script.

Looks like some versions of the buildfarm script try to set the port via
--port in $EXTRA_REGRESS_OPTS.  Override that ...

12 years agoMake pg_upgrade's test script attempt to select a non-conflicting port.
Tom Lane [Sat, 11 May 2013 18:22:18 +0000 (14:22 -0400)]
Make pg_upgrade's test script attempt to select a non-conflicting port.

Previously, the port number used in this test script was hard-wired at
pg_upgrade's default of 50432; which is not so great because parallel build
runs might conflict.  Commit 3d53173e20d151341f894f79d556768c845ba3e4
removed this setting for the postmasters started by the script proper
(not by pg_upgrade), which didn't do anything to fix that problem and also
guaranteed a failure if there was a live postmaster at the build's default
port number.  Instead, select a non-conflicting temporary port number in
the same way that pg_regress.c does.  (Its method isn't entirely
bulletproof, but given the lack of complaints I'm not going to worry
about that today.)

In passing, unset MAKEFLAGS and MAKELEVEL to avoid problems with the
script's internal invocations of make, for the same reason pg_regress.c
does: it could cause problems in a parallel make.

12 years agoUpdate CREATE FUNCTION documentation about argument names.
Tom Lane [Sat, 11 May 2013 16:07:47 +0000 (12:07 -0400)]
Update CREATE FUNCTION documentation about argument names.

The 9.2 patch that added argument name support in SQL-language functions
missed updating a parenthetical comment about that in the CREATE FUNCTION
reference page.  Noted by Erwin Brandstetter.

12 years agoGuard against input_rows == 0 in estimate_num_groups().
Tom Lane [Fri, 10 May 2013 21:15:30 +0000 (17:15 -0400)]
Guard against input_rows == 0 in estimate_num_groups().

This case doesn't normally happen, because the planner usually clamps
all row estimates to at least one row; but I found that it can arise
when dealing with relations excluded by constraints.  Without a defense,
estimate_num_groups() can return zero, which leads to divisions by zero
inside the planner as well as assertion failures in the executor.

An alternative fix would be to change set_dummy_rel_pathlist() to make
the size estimate for a dummy relation 1 row instead of 0, but that seemed
pretty ugly; and probably someday we'll want to drop the convention that
the minimum rowcount estimate is 1 row.

Back-patch to 8.4, as the problem can be demonstrated that far back.

12 years agoFix pgp_pub_decrypt() so it works for secret keys with passwords.
Tom Lane [Fri, 10 May 2013 17:06:48 +0000 (13:06 -0400)]
Fix pgp_pub_decrypt() so it works for secret keys with passwords.

Per report from Keith Fiske.

Marko Kreen

12 years agoFix management of fn_extra caching during repeated GiST index scans.
Tom Lane [Fri, 10 May 2013 03:08:19 +0000 (23:08 -0400)]
Fix management of fn_extra caching during repeated GiST index scans.

Commit d22a09dc70f9830fa78c1cd1a3a453e4e473d354 introduced official support
for GiST consistentFns that want to cache data using the FmgrInfo fn_extra
pointer: the idea was to preserve the cached values across gistrescan(),
whereas formerly they'd been leaked.  However, there was an oversight in
that, namely that multiple scan keys might reference the same column's
consistentFn; the code would result in propagating the same cache value
into multiple scan keys, resulting in crashes or wrong answers.  Use a
separate array instead to ensure that each scan key keeps its own state.

Per bug #8143 from Joel Roller.  Back-patch to 9.2 where the bug was
introduced.

12 years agoUpdate key words table for 9.3
Peter Eisentraut [Fri, 10 May 2013 02:26:04 +0000 (22:26 -0400)]
Update key words table for 9.3

12 years agoRemove make_keywords
Peter Eisentraut [Fri, 10 May 2013 02:21:43 +0000 (22:21 -0400)]
Remove make_keywords

It is not used anymore.

12 years agoUse pg_dump's --quote-all-identifiers option in pg_upgrade.
Tom Lane [Thu, 9 May 2013 21:34:34 +0000 (17:34 -0400)]
Use pg_dump's --quote-all-identifiers option in pg_upgrade.

This helps guard against changes in the set of reserved keywords from
one version to another.  In theory it should only be an issue if we
de-reserve a keyword in a newer release, since that can create the type
of problem shown in bug #8128.

Back-patch to 9.1 where the --quote-all-identifiers option was added.

12 years agopg_upgrade docs: give tips on automation
Bruce Momjian [Thu, 9 May 2013 20:05:26 +0000 (16:05 -0400)]
pg_upgrade docs:  give tips on automation

Document that post-upgrade steps are likely to be the same for all
clusters with the same DDL/schemas;  this should help automated
upgrades.

12 years agoUpdate collate.linux.utf8.out for ruleutils.c line-wrapping changes.
Tom Lane [Thu, 9 May 2013 02:47:33 +0000 (22:47 -0400)]
Update collate.linux.utf8.out for ruleutils.c line-wrapping changes.

Missed in commit 62e666400dddf605b9b6d9a7ac2918711b5c5629.

12 years agoBetter fix for permissions tests in excluded subqueries.
Tom Lane [Wed, 8 May 2013 20:59:09 +0000 (16:59 -0400)]
Better fix for permissions tests in excluded subqueries.

This reverts the code changes in 50c137487c96e629e0e5372bb3d1b5f1a2f71a88,
which turned out to induce crashes and not completely fix the problem
anyway.  That commit only considered single subqueries that were excluded
by constraint-exclusion logic, but actually the problem also exists for
subqueries that are appendrel members (ie part of a UNION ALL list).  In
such cases we can't add a dummy subpath to the appendrel's AppendPath list
without defeating the logic that recognizes when an appendrel is completely
excluded.  Instead, fix the problem by having setrefs.c scan the rangetable
an extra time looking for subqueries that didn't get into the plan tree.
(This approach depends on the 9.2 change that made set_subquery_pathlist
generate dummy paths for excluded single subqueries, so that the exclusion
behavior is the same for single subqueries and appendrel members.)

Note: it turns out that the appendrel form of the missed-permissions-checks
bug exists as far back as 8.4.  However, since the practical effect of that
bug seems pretty minimal, consensus is to not attempt to fix it in the back
branches, at least not yet.  Possibly we could back-port this patch once
it's gotten a reasonable amount of testing in HEAD.  For the moment I'm
just going to revert the previous patch in 9.2.

12 years agoThe data structure used in unaccent is a trie, not suffix tree.
Heikki Linnakangas [Wed, 8 May 2013 17:57:42 +0000 (20:57 +0300)]
The data structure used in unaccent is a trie, not suffix tree.

Fix the term used in variable and struct names, and comments.

Alexander Korotkov

12 years agoFix walsender failure at promotion.
Heikki Linnakangas [Wed, 8 May 2013 17:10:17 +0000 (20:10 +0300)]
Fix walsender failure at promotion.

If a standby server has a cascading standby server connected to it, it's
possible that WAL has already been sent up to the next WAL page boundary,
splitting a WAL record in the middle, when the first standby server is
promoted. Don't throw an assertion failure or error in walsender if that
happens.

Also, fix a variant of the same bug in pg_receivexlog: if it had already
received WAL on previous timeline up to a segment boundary, when the
upstream standby server is promoted so that the timeline switch record falls
on the previous segment, pg_receivexlog would miss the segment containing
the timeline switch. To fix that, have walsender send the position of the
timeline switch at end-of-streaming, in addition to the next timeline's ID.
It was previously assumed that the switch happened exactly where the
streaming stopped.

Note: this is an incompatible change in the streaming protocol. You might
get an error if you try to stream over timeline switches, if the client is
running 9.3beta1 and the server is more recent. It should be fine after a
reconnect, however.

Reported by Fujii Masao.

12 years agoUse the term "radix tree" instead of "suffix tree" for SP-GiST text opclass.
Heikki Linnakangas [Wed, 8 May 2013 11:29:28 +0000 (14:29 +0300)]
Use the term "radix tree" instead of "suffix tree" for SP-GiST text opclass.

What we have implemented is a radix tree (or a radix trie or a patricia
trie), but the docs and code comments incorrectly called it a "suffix tree".

Alexander Korotkov

12 years agodoc: Add IDs to link targets used by phpPgAdmin
Peter Eisentraut [Wed, 8 May 2013 01:23:21 +0000 (21:23 -0400)]
doc: Add IDs to link targets used by phpPgAdmin

Karl O. Pinc

12 years agoStress that backup_label file is critical in the docs.
Heikki Linnakangas [Tue, 7 May 2013 13:55:04 +0000 (16:55 +0300)]
Stress that backup_label file is critical in the docs.

It is surprisingly common mistake to leave out backup_label file from a base
backup. Say more explicitly that it must be included.

Jeff Janes, with minor rewording by me.

12 years agoStamp 9.3beta1.
Tom Lane [Mon, 6 May 2013 20:57:06 +0000 (16:57 -0400)]
Stamp 9.3beta1.

12 years agoDesultory copy-editing of the 9.3 release notes.
Tom Lane [Mon, 6 May 2013 20:02:37 +0000 (16:02 -0400)]
Desultory copy-editing of the 9.3 release notes.

I had time for a quick review of the notes, so here are some fixes.

12 years agoMove materialized views' is-populated status into their pg_class entries.
Tom Lane [Mon, 6 May 2013 17:26:51 +0000 (13:26 -0400)]
Move materialized views' is-populated status into their pg_class entries.

Previously this state was represented by whether the view's disk file had
zero or nonzero size, which is problematic for numerous reasons, since it's
breaking a fundamental assumption about heap storage.  This was done to
allow unlogged matviews to revert to unpopulated status after a crash
despite our lack of any ability to update catalog entries post-crash.
However, this poses enough risk of future problems that it seems better to
not support unlogged matviews until we can find another way.  Accordingly,
revert that choice as well as a number of existing kluges forced by it
in favor of creating a pg_class.relispopulated flag column.

12 years agoBack out some recent translation updates.
Tom Lane [Mon, 6 May 2013 16:28:13 +0000 (12:28 -0400)]
Back out some recent translation updates.

Very old versions of msgfmt choke on these specific messages, for reasons
that are unclear at the moment.  Remove them so that we can ship a beta
release and not get complaints from testers (these messages will just go
untranslated, instead, and we're hardly at 100% coverage anyway).
Peter Eisentraut will look for a better fix later.

12 years agoDisallow unlogged materialized views.
Tom Lane [Mon, 6 May 2013 15:57:05 +0000 (11:57 -0400)]
Disallow unlogged materialized views.

The initial implementation of this feature was really unsupportable,
because it's relying on the physical size of an on-disk file to carry the
relation's populated/unpopulated state, which is at least a modularity
violation and could have serious long-term consequences.  We could say that
an unlogged matview goes to empty on crash, but not everybody likes that
definition, so let's just remove the feature for 9.3.  We can add it back
when we have a less klugy implementation.

I left the grammar and tab-completion support for CREATE UNLOGGED
MATERIALIZED VIEW in place, since it's harmless and allows delivering a
more specific error message about the unsupported feature.

I'm committing this separately to ease identification of what should be
reverted when/if we are able to re-enable the feature.

12 years ago9.3 release notes: use "restoration"
Bruce Momjian [Mon, 6 May 2013 14:57:23 +0000 (10:57 -0400)]
9.3 release notes:  use "restoration"

Andrew Dunstan

12 years ago9.3 release notes: Add cache of local locks
Bruce Momjian [Mon, 6 May 2013 14:56:27 +0000 (10:56 -0400)]
9.3 release notes: Add cache of local locks

Mention this also helps in the restoring of pg_dumps.

Jeff Janes

12 years ago9.3 release notes: update from Amit Kapila
Bruce Momjian [Mon, 6 May 2013 14:47:10 +0000 (10:47 -0400)]
9.3 release notes:  update from Amit Kapila

No need to mention wal_receiver_status_interval.

12 years agoExecute SET TRANSACTION SNAPSHOT during pg_dump
Simon Riggs [Mon, 6 May 2013 14:37:17 +0000 (15:37 +0100)]
Execute SET TRANSACTION SNAPSHOT during pg_dump
Previous coding set the SQL buffer but never executed

Bug noted by me during beta testing

12 years agoRevert idea of zer-padding padding session id in log_line_prefix
Bruce Momjian [Mon, 6 May 2013 12:59:39 +0000 (08:59 -0400)]
Revert idea of zer-padding padding session id in log_line_prefix

Removal of doc adjustment and release note mention as well.

12 years agoTranslation updates
Peter Eisentraut [Mon, 6 May 2013 02:34:23 +0000 (22:34 -0400)]
Translation updates

12 years agoImprove behavior of \watch with non-tuple-returning commands.
Tom Lane [Sat, 4 May 2013 20:41:22 +0000 (16:41 -0400)]
Improve behavior of \watch with non-tuple-returning commands.

Print the command tag if we get PGRES_COMMAND_OK, and throw an error for
other cases.  Per gripe from Michael Paquier.

In passing, add an fflush(), just to be real sure the output appears
before we sleep.

12 years agodocs: Improve log_line_prefix session_id query
Bruce Momjian [Sat, 4 May 2013 17:23:04 +0000 (13:23 -0400)]
docs:  Improve log_line_prefix session_id query

12 years agodocs: log_line_prefix session id fix
Bruce Momjian [Sat, 4 May 2013 17:15:54 +0000 (13:15 -0400)]
docs:  log_line_prefix session id fix

Restore 4-byte designation for docs.  Fix 9.3 doc query to properly pad
to four digits.

Backpatch to all active branches

Per suggestions from Ian Lawrence Barwick