]> granicus.if.org Git - postgresql/log
postgresql
10 years agoIn checkpoint, move the check for in-progress xacts out of critical section.
Heikki Linnakangas [Fri, 4 Apr 2014 14:29:50 +0000 (17:29 +0300)]
In checkpoint, move the check for in-progress xacts out of critical section.

GetVirtualXIDsDelayingChkpt calls palloc, which isn't safe in a critical
section. I thought I covered this case with the exemption for the
checkpointer, but CreateCheckPoint is also called from the startup process.

10 years agoAdd an Assertion that you don't palloc within a critical section.
Heikki Linnakangas [Fri, 4 Apr 2014 11:27:18 +0000 (14:27 +0300)]
Add an Assertion that you don't palloc within a critical section.

This caught a bunch of cases doing that already, which I just fixed in
previous commit. This is the assertion itself.

Per Tom Lane's idea.

10 years agoAvoid allocations in critical sections.
Heikki Linnakangas [Fri, 4 Apr 2014 10:12:38 +0000 (13:12 +0300)]
Avoid allocations in critical sections.

If a palloc in a critical section fails, it becomes a PANIC.

10 years agoFix non-equivalence of VARIADIC and non-VARIADIC function call formats.
Tom Lane [Fri, 4 Apr 2014 02:02:24 +0000 (22:02 -0400)]
Fix non-equivalence of VARIADIC and non-VARIADIC function call formats.

For variadic functions (other than VARIADIC ANY), the syntaxes foo(x,y,...)
and foo(VARIADIC ARRAY[x,y,...]) should be considered equivalent, since the
former is converted to the latter at parse time.  They have indeed been
equivalent, in all releases before 9.3.  However, commit 75b39e790 made an
ill-considered decision to record which syntax had been used in FuncExpr
nodes, and then to make equal() test that in checking node equality ---
which caused the syntaxes to not be seen as equivalent by the planner.
This is the underlying cause of bug #9817 from Dmitry Ryabov.

It might seem that a quick fix would be to make equal() disregard
FuncExpr.funcvariadic, but the same commit made that untenable, because
the field actually *is* semantically significant for some VARIADIC ANY
functions.  This patch instead adopts the approach of redefining
funcvariadic (and aggvariadic, in HEAD) as meaning that the last argument
is a variadic array, whether it got that way by parser intervention or was
supplied explicitly by the user.  Therefore the value will always be true
for non-ANY variadic functions, restoring the principle of equivalence.
(However, the planner will continue to consider use of VARIADIC as a
meaningful difference for VARIADIC ANY functions, even though some such
functions might disregard it.)

In HEAD, this change lets us simplify the decompilation logic in
ruleutils.c, since the funcvariadic/aggvariadic flag tells directly whether
to print VARIADIC.  However, in 9.3 we have to continue to cope with
existing stored rules/views that might contain the previous definition.
Fortunately, this just means no change in ruleutils.c, since its existing
behavior effectively ignores funcvariadic for all cases other than VARIADIC
ANY functions.

In HEAD, bump catversion to reflect the fact that FuncExpr.funcvariadic
changed meanings; this is sort of pro forma, since I don't believe any
built-in views are affected.

Unfortunately, this patch doesn't magically fix everything for affected
9.3 users.  After installing 9.3.5, they might need to recreate their
rules/views/indexes containing variadic function calls in order to get
everything consistent with the new definition.  As in the cited bug,
the symptom of a problem would be failure to use a nominally matching
index that has a variadic function call in its definition.  We'll need
to mention this in the 9.3.5 release notes.

10 years agoCode review for commit d26888bc4d1e539a82f21382b0000fe5bbf889d9.
Tom Lane [Thu, 3 Apr 2014 20:57:45 +0000 (16:57 -0400)]
Code review for commit d26888bc4d1e539a82f21382b0000fe5bbf889d9.

Mostly, copy-edit the comments; but also fix it to not reject domains over
arrays.

10 years agoFix documentation about joining pg_locks to other views.
Tom Lane [Thu, 3 Apr 2014 18:18:25 +0000 (14:18 -0400)]
Fix documentation about joining pg_locks to other views.

The advice to join to pg_prepared_xacts via the transaction column was not
updated when the transaction column was replaced by virtualtransaction.
Since it's not quite obvious how to do that join, give an explicit example.
For consistency also give an example for the adjacent case of joining to
pg_stat_activity.  And link-ify the view references too, just because we
can.  Per bug #9840 from Alexey Bashtanov.

Michael Paquier and Tom Lane

10 years agoAvoid promising that "ADD COLUMN ... DEFAULT NULL" is free.
Tom Lane [Thu, 3 Apr 2014 16:38:00 +0000 (12:38 -0400)]
Avoid promising that "ADD COLUMN ... DEFAULT NULL" is free.

The system realizes that DEFAULT NULL is dummy in simple cases, but not if
a cast function (such as a length coercion) needs to be applied.  It's
dubious that suppressing that function call would be appropriate, anyway.
For the moment, let's just adjust the docs to say that you should omit the
DEFAULT clause if you don't want a rewrite to happen.  Per gripe from Amit
Langote.

10 years agoAvoid palloc in critical section in GiST WAL-logging.
Heikki Linnakangas [Thu, 3 Apr 2014 12:09:37 +0000 (15:09 +0300)]
Avoid palloc in critical section in GiST WAL-logging.

Memory allocation can fail if you run out of memory, and inside a critical
section that will lead to a PANIC. Use conservatively-sized arrays in stack
instead.

There was previously no explicit limit on the number of pages a GiST split
can produce, it was only limited by the number of LWLocks that can be held
simultaneously (100 at the moment). This patch adds an explicit limit of 75
pages. That should be plenty, a typical split shouldn't produce more than
2-3 page halves.

The bug has been there forever, but only backpatch down to 9.1. The code
was changed significantly in 9.1, and it doesn't seem worth the risk or
trouble to adapt this for 9.0 and 8.4.

10 years agoFix assorted issues in client host name lookup.
Tom Lane [Wed, 2 Apr 2014 21:11:24 +0000 (17:11 -0400)]
Fix assorted issues in client host name lookup.

The code for matching clients to pg_hba.conf lines that specify host names
(instead of IP address ranges) failed to complain if reverse DNS lookup
failed; instead it silently didn't match, so that you might end up getting
a surprising "no pg_hba.conf entry for ..." error, as seen in bug #9518
from Mike Blackwell.  Since we don't want to make this a fatal error in
situations where pg_hba.conf contains a mixture of host names and IP
addresses (clients matching one of the numeric entries should not have to
have rDNS data), remember the lookup failure and mention it as DETAIL if
we get to "no pg_hba.conf entry".  Apply the same approach to forward-DNS
lookup failures, too, rather than treating them as immediate hard errors.

Along the way, fix a couple of bugs that prevented us from detecting an
rDNS lookup error reliably, and make sure that we make only one rDNS lookup
attempt; formerly, if the lookup attempt failed, the code would try again
for each host name entry in pg_hba.conf.  Since more or less the whole
point of this design is to ensure there's only one lookup attempt not one
per entry, the latter point represents a performance bug that seems
sufficient justification for back-patching.

Also, adjust src/port/getaddrinfo.c so that it plays as well as it can
with this code.  Which is not all that well, since it does not have actual
support for rDNS lookup, but at least it should return the expected (and
required by spec) error codes so that the main code correctly perceives the
lack of functionality as a lookup failure.  It's unlikely that PG is still
being used in production on any machines that require our getaddrinfo.c,
so I'm not excited about working harder than this.

To keep the code in the various branches similar, this includes
back-patching commits c424d0d1052cb4053c8712ac44123f9b9a9aa3f2 and
1997f34db4687e671690ed054c8f30bb501b1168 into 9.2 and earlier.

Back-patch to 9.1 where the facility for hostnames in pg_hba.conf was
introduced.

10 years agoDe-anonymize the union in JsonbValue.
Tom Lane [Wed, 2 Apr 2014 18:30:08 +0000 (14:30 -0400)]
De-anonymize the union in JsonbValue.

Needed for strict C89 compliance.

10 years agoFix bugs in manipulation of PgBackendStatus.st_clienthostname.
Tom Lane [Wed, 2 Apr 2014 01:30:08 +0000 (21:30 -0400)]
Fix bugs in manipulation of PgBackendStatus.st_clienthostname.

Initialization of this field was not being done according to the
st_changecount protocol (it has to be done within the changecount increment
range, not outside).  And the test to see if the value should be reported
as null was wrong.  Noted while perusing uses of Port.remote_hostname.

This was wrong from the introduction of this code (commit 4a25bc145),
so back-patch to 9.1.

10 years agoFix bug in the new GIN incomplete-split code.
Heikki Linnakangas [Tue, 1 Apr 2014 19:45:10 +0000 (22:45 +0300)]
Fix bug in the new GIN incomplete-split code.

Inserting a downlink to an internal page clears the incomplete-split flag
of the child's left sibling, so the left sibling's LSN also needs to be
updated and it needs to be marked dirty. The codepath for an insertion got
this right, but the case where the internal node is split because of
inserting the new downlink missed that.

10 years agoDoc: improve discussion of reverse+forward host name lookup in pg_hba.conf.
Tom Lane [Tue, 1 Apr 2014 19:20:30 +0000 (15:20 -0400)]
Doc: improve discussion of reverse+forward host name lookup in pg_hba.conf.

Fix some grammatical issues and make it a bit more readable.

10 years agoRemove dead check for backup block, replace with Assert.
Heikki Linnakangas [Tue, 1 Apr 2014 18:16:10 +0000 (21:16 +0300)]
Remove dead check for backup block, replace with Assert.

We don't use backup blocks with GIN vacuum records anymore, the page is
always recreated from scratch.

10 years agoFix bug in the new B-tree incomplete-split code.
Heikki Linnakangas [Tue, 1 Apr 2014 16:19:47 +0000 (19:19 +0300)]
Fix bug in the new B-tree incomplete-split code.

Inserting a downlink to an internal page clears the incomplete-split flag
of the child's left sibling, so the left sibling's LSN also needs to be
updated.

10 years agoMove SizeOfHeapNewCid next to xl_heap_new_cid struct.
Heikki Linnakangas [Tue, 1 Apr 2014 13:23:16 +0000 (16:23 +0300)]
Move SizeOfHeapNewCid next to xl_heap_new_cid struct.

They belong together, but the xl_heap_rewrite_mapping struct was wedged
in between.

10 years agoFix typo in comment.
Heikki Linnakangas [Tue, 1 Apr 2014 06:27:37 +0000 (09:27 +0300)]
Fix typo in comment.

Amit Langote

10 years agoMark FastPathStrongRelationLocks volatile.
Robert Haas [Mon, 31 Mar 2014 18:32:12 +0000 (14:32 -0400)]
Mark FastPathStrongRelationLocks volatile.

Otherwise, the compiler might decide to move modifications to data
within this structure outside the enclosing SpinLockAcquire /
SpinLockRelease pair, leading to shared memory corruption.

This may or may not explain a recent lmgr-related buildfarm failure
on prairiedog, but it needs to be fixed either way.

10 years agotest_decoding: Update .gitignore
Robert Haas [Mon, 31 Mar 2014 18:18:35 +0000 (14:18 -0400)]
test_decoding: Update .gitignore

Commit 7317d8d961f210c3a6b20972cd605bcd9bffb06e changed the set of
things that need to be ignored, but neglected to update .gitignore.

10 years agoCount buffers dirtied due to hints in pgBufferUsage.shared_blks_dirtied.
Robert Haas [Mon, 31 Mar 2014 17:06:26 +0000 (13:06 -0400)]
Count buffers dirtied due to hints in pgBufferUsage.shared_blks_dirtied.

Previously, such buffers weren't counted, with the possible result that
EXPLAIN (BUFFERS) and pg_stat_statements would understate the true
number of blocks dirtied by an SQL statement.

Back-patch to 9.2, where this counter was introduced.

Amit Kapila

10 years agoFix thinko in logical decoding code.
Robert Haas [Mon, 31 Mar 2014 17:03:18 +0000 (13:03 -0400)]
Fix thinko in logical decoding code.

Andres Freund

10 years agoRewrite the way GIN posting lists are packed on a page, to reduce WAL volume.
Heikki Linnakangas [Mon, 31 Mar 2014 12:15:19 +0000 (15:15 +0300)]
Rewrite the way GIN posting lists are packed on a page, to reduce WAL volume.

Inserting (in retail) into the new 9.4 format GIN posting tree created much
larger WAL records than in 9.3. The previous strategy to WAL logging was
basically to log the whole page on each change, with the exception of
completely unmodified segments up to the first modified one. That was not
too bad when appending to the end of the page, as only the last segment had
to be WAL-logged, but per Fujii Masao's testing, even that produced 2x the
WAL volume that 9.3 did.

The new strategy is to keep track of changes to the posting lists in a more
fine-grained fashion, and also make the repacking" code smarter to avoid
decoding and re-encoding segments unnecessarily.

10 years agoRename GinLogicValue to GinTernaryValue.
Heikki Linnakangas [Mon, 31 Mar 2014 07:26:38 +0000 (10:26 +0300)]
Rename GinLogicValue to GinTernaryValue.

It's more descriptive. Also, get rid of the enum, and use #defines instead,
per Greg Stark's suggestion.

10 years agoUse separate output dirs for test_decoding's two runs.
Andrew Dunstan [Sun, 30 Mar 2014 22:30:59 +0000 (18:30 -0400)]
Use separate output dirs for test_decoding's two runs.

contrib/test_decoding's "make check" runs two sets of tests. Unless we
specify separate output directories for each set the isolation tests
will overwrite the output from the  normal regression set. Doing this
will help the buildfarm collect complete logs.

10 years agopsql: display "Replica Identity" only for FULL and NOTHING
Bruce Momjian [Sat, 29 Mar 2014 23:00:11 +0000 (19:00 -0400)]
psql:  display "Replica Identity" only for FULL and NOTHING

INDEX is already displayed on the index, and we now exclude pg_catalog.
DEFAULT is not displayed.

10 years agoFix dumping of a materialized view that depends on a table's primary key.
Tom Lane [Sat, 29 Mar 2014 21:34:00 +0000 (17:34 -0400)]
Fix dumping of a materialized view that depends on a table's primary key.

It is possible for a view or materialized view to depend on a table's
primary key, if the view query relies on functional dependency to
abbreviate a GROUP BY list.  This is problematic for pg_dump since we
ordinarily want to dump view definitions in the pre-data section but
indexes in post-data.  pg_dump knows how to deal with this situation for
regular views, by breaking the view's ON SELECT rule apart from the view
proper.  But it had not been taught what to do about materialized views,
and in fact mistakenly dumped them as regular views in such cases, as
seen in bug #9616 from Jesse Denardo.

If we had CREATE OR REPLACE MATERIALIZED VIEW, we could fix this in a
manner analogous to what's done for regular views; but we don't yet,
and we'd not back-patch such a thing into 9.3 anyway.  As a hopefully-
temporary workaround, break the circularity by postponing the matview
into post-data altogether when this case occurs.

10 years agoRevert "Secure Unix-domain sockets of "make check" temporary clusters."
Noah Misch [Sat, 29 Mar 2014 07:12:00 +0000 (03:12 -0400)]
Revert "Secure Unix-domain sockets of "make check" temporary clusters."

About half of the buildfarm members use too-long directory names,
strongly suggesting that this approach is a dead end.

10 years agoSecure Unix-domain sockets of "make check" temporary clusters.
Noah Misch [Sat, 29 Mar 2014 04:52:56 +0000 (00:52 -0400)]
Secure Unix-domain sockets of "make check" temporary clusters.

Any OS user able to access the socket can connect as the bootstrap
superuser and in turn execute arbitrary code as the OS user running the
test.  Protect against that by placing the socket in the temporary data
directory, which has mode 0700 thanks to initdb.  Back-patch to 8.4 (all
supported versions).  The hazard remains wherever the temporary cluster
accepts TCP connections, notably on Windows.

Attempts to run "make check" from a directory with a long name will now
fail.  An alternative not sharing that problem was to place the socket
in a subdirectory of /tmp, but that is only secure if /tmp is sticky.
The PG_REGRESS_SOCK_DIR environment variable is available as a
workaround when testing from long directory paths.

As a convenient side effect, this lets testing proceed smoothly in
builds that override DEFAULT_PGSOCKET_DIR.  Popular non-default values
like /var/run/postgresql are often unwritable to the build user.

Security: CVE-2014-0067

10 years agoDocument platform-specificity of unix_socket_permissions.
Noah Misch [Sat, 29 Mar 2014 04:52:31 +0000 (00:52 -0400)]
Document platform-specificity of unix_socket_permissions.

Back-patch to 8.4 (all supported versions).

10 years agoForce consistent row order in contrib/test_decoding regression test.
Noah Misch [Sat, 29 Mar 2014 04:31:44 +0000 (00:31 -0400)]
Force consistent row order in contrib/test_decoding regression test.

10 years agoImprove regression test for pg_filenode_relation().
Tom Lane [Fri, 28 Mar 2014 20:58:09 +0000 (16:58 -0400)]
Improve regression test for pg_filenode_relation().

Make it print the details in case there's a failure.

Andres Freund, slightly modified by me

10 years agoAdjust getpwuid() fix commit to display errno string on failure
Bruce Momjian [Fri, 28 Mar 2014 16:50:11 +0000 (12:50 -0400)]
Adjust getpwuid() fix commit to display errno string on failure

This adjusts patch 613c6d26bd42dd8c2dd0664315be9551475b8864.

10 years agoFix EquivalenceClass processing for nested append relations.
Tom Lane [Fri, 28 Mar 2014 15:50:01 +0000 (11:50 -0400)]
Fix EquivalenceClass processing for nested append relations.

The original coding of EquivalenceClasses didn't foresee that appendrel
child relations might themselves be appendrels; but this is possible for
example when a UNION ALL subquery scans a table with inheritance children.
The oversight led to failure to optimize ordering-related issues very well
for the grandchild tables.  After some false starts involving explicitly
flattening the appendrel representation, we found that this could be fixed
easily by removing a few implicit assumptions about appendrel parent rels
not being children themselves.

Kyotaro Horiguchi and Tom Lane, reviewed by Noah Misch

10 years agoUn-break peer authentication.
Tom Lane [Fri, 28 Mar 2014 14:30:37 +0000 (10:30 -0400)]
Un-break peer authentication.

Commit 613c6d26bd42dd8c2dd0664315be9551475b8864 sloppily replaced a
lookup of the UID obtained from getpeereid() with a lookup of the
server's own user name, thus totally destroying peer authentication.
Revert.  Per report from Christoph Berg.

In passing, make sure get_user_name() zeroes *errstr on success on
Windows as well as non-Windows.  I don't think any callers actually
depend on this ATM, but we should be consistent across platforms.

10 years agoImprove documentation note about Python 2.3 and cdecimal.
Tom Lane [Thu, 27 Mar 2014 21:15:45 +0000 (17:15 -0400)]
Improve documentation note about Python 2.3 and cdecimal.

Explain exactly what fails (ie, function arguments of type numeric)
if you don't have it.

10 years agocontrib/test_decoding: adjust expected output
Bruce Momjian [Thu, 27 Mar 2014 14:47:48 +0000 (10:47 -0400)]
contrib/test_decoding:  adjust expected output

Expected output has changed because of psql replica identity output
changes.

Reported by Christoph Berg

10 years agoSilence compiler warnings in new jsonb code.
Heikki Linnakangas [Thu, 27 Mar 2014 06:53:44 +0000 (08:53 +0200)]
Silence compiler warnings in new jsonb code.

Amit Kapila.

10 years agoDocument that Python 2.3 requires cdecimal module for full functionality.
Tom Lane [Thu, 27 Mar 2014 02:43:22 +0000 (22:43 -0400)]
Document that Python 2.3 requires cdecimal module for full functionality.

This has been true for some time, but we were leaving users to discover it
the hard way.

Back-patch to 9.2.  It might've been true before that, but we were claiming
Python 2.2 compatibility before that, so I won't guess at the exact
requirements back then.

10 years agoFix uninitialized variables in json's populate_record_worker().
Andrew Dunstan [Wed, 26 Mar 2014 22:20:56 +0000 (18:20 -0400)]
Fix uninitialized variables in json's populate_record_worker().

Peter Geoghegan.

10 years agoFix refcounting bug in PLy_modify_tuple().
Tom Lane [Wed, 26 Mar 2014 20:41:32 +0000 (16:41 -0400)]
Fix refcounting bug in PLy_modify_tuple().

We must increment the refcount on "plntup" as soon as we have the
reference, not sometime later.  Otherwise, if an error is thrown in
between, the Py_XDECREF(plntup) call in the PG_CATCH block removes a
refcount we didn't add, allowing the object to be freed even though
it's still part of the plpython function's parsetree.

This appears to be the cause of crashes seen on buildfarm member
prairiedog.  It's a bit surprising that we've not seen it fail repeatably
before, considering that the regression tests have been exercising the
faulty code path since 2009.

The real-world impact is probably minimal, since it's unlikely anyone would
be provoking the "TD["new"] is not a dictionary" error in production, and
that's the only case that is actually wrong.  Still, it's a bug affecting
the regression tests, so patch all supported branches.

In passing, remove dead variable "plstr", and demote "platt" to a local
variable inside the PG_TRY block, since we don't need to clean it up
in the PG_CATCH path.

10 years agoPass more than the first XLogRecData entry to rm_desc, with WAL_DEBUG.
Heikki Linnakangas [Wed, 26 Mar 2014 16:04:57 +0000 (18:04 +0200)]
Pass more than the first XLogRecData entry to rm_desc, with WAL_DEBUG.

If you compile with WAL_DEBUG and enable it with wal_debug=on, we used to
only pass the first XLogRecData entry to the rm_desc routine. I think the
original assumprion was that the first XLogRecData entry contains all the
necessary information for the rm_desc routine, but that's a pretty shaky
assumption. At least standby_redo didn't get the memo.

To fix, piece together all the data in a temporary buffer, and pass that to
the rm_desc routine.

It's been like this forever, but the patch didn't apply cleanly to
back-branches. Probably wouldn't be hard to fix the conflicts, but it's
not worth the trouble.

10 years agopsql: update "replica identity" display for \d+
Bruce Momjian [Wed, 26 Mar 2014 15:13:17 +0000 (11:13 -0400)]
psql:  update "replica identity" display for \d+

Display "replica identity" only for \d plus mode, exclude system schema
objects, and display all possible values, not just non-default,
non-index ones.

10 years agopg_upgrade: use pg_usleep(); remove Windows workaround
Bruce Momjian [Wed, 26 Mar 2014 14:22:16 +0000 (10:22 -0400)]
pg_upgrade: use pg_usleep();  remove Windows workaround

10 years agoCleanup around json_to_record/json_to_recordset
Andrew Dunstan [Wed, 26 Mar 2014 14:18:24 +0000 (10:18 -0400)]
Cleanup around json_to_record/json_to_recordset

Set function parameter names and defaults. Add jsonb versions (which the
code already provided for so the actual new code is trivial). Add jsonb
regression tests and docs.

Bump catalog version (which I apparently forgot to do when jsonb was
committed).

10 years agoUse pg_usleep() instead of plain sleep(), to fix Windows build
Heikki Linnakangas [Wed, 26 Mar 2014 13:25:39 +0000 (15:25 +0200)]
Use pg_usleep() instead of plain sleep(), to fix Windows build

Per buildfarm.

10 years agoAdd -f/--follow option to pg_xlogdump.
Heikki Linnakangas [Wed, 26 Mar 2014 11:48:20 +0000 (13:48 +0200)]
Add -f/--follow option to pg_xlogdump.

This is useful for seeing what WAL records are inserted in real-time, by
pointing pg_xlogdump to a live server.

10 years agoFix 'recheck' flag in tsquery's GIN tri-consistent function.
Heikki Linnakangas [Wed, 26 Mar 2014 08:13:44 +0000 (10:13 +0200)]
Fix 'recheck' flag in tsquery's GIN tri-consistent function.

It needs to be initialized, like in the boolean gin_tsquery_consistent
version.

Peter Geoghegan.

10 years agoTidy up the populate/to_record{set} code for json a bit.
Andrew Dunstan [Wed, 26 Mar 2014 01:20:54 +0000 (21:20 -0400)]
Tidy up the populate/to_record{set} code for json a bit.

In the process fix a small bug.

10 years agoDon't forget to flush XLOG_PARAMETER_CHANGE record.
Fujii Masao [Tue, 25 Mar 2014 17:12:39 +0000 (02:12 +0900)]
Don't forget to flush XLOG_PARAMETER_CHANGE record.

Backpatch to 9.0 where XLOG_PARAMETER_CHANGE record was instroduced.

10 years agoFix typos in pg_basebackup documentation
Magnus Hagander [Tue, 25 Mar 2014 10:16:57 +0000 (11:16 +0100)]
Fix typos in pg_basebackup documentation

Joshua Tolley

10 years agodoc: list unlogged tables as a non-durable option
Bruce Momjian [Tue, 25 Mar 2014 02:04:44 +0000 (22:04 -0400)]
doc:  list unlogged tables as a non-durable option

10 years agoRemove wchar.c Asserts that were stricter than the main code
Bruce Momjian [Mon, 24 Mar 2014 19:59:38 +0000 (15:59 -0400)]
Remove wchar.c Asserts that were stricter than the main code

Assert errors were thrown for functions being passed invalid encodings,
while the main code handled it just fine.

Also document that libpq's PQclientEncoding() returns -1 for an encoding
lookup failure.

Per report from Peter Geoghegan

10 years agodocs: Add short "cover density" description
Bruce Momjian [Mon, 24 Mar 2014 19:46:59 +0000 (15:46 -0400)]
docs:  Add short "cover density" description

Also, previous commit 1420f3a9827a39e5c6c998f6fa35a6fc97903145 to fix
ts_rank_cd() for stripped lexemes was from a patch created by Alex Hill.

10 years agoFix ts_rank_cd() to ignore stripped lexemes
Bruce Momjian [Mon, 24 Mar 2014 18:36:36 +0000 (14:36 -0400)]
Fix ts_rank_cd() to ignore stripped lexemes

Previously, stripped lexemes got a default location and could be
considered if mixed with non-stripped lexemes.

BACKWARD INCOMPATIBILITY CHANGE

10 years agoChange ginMergeItemPointers to return a palloc'd array.
Heikki Linnakangas [Mon, 24 Mar 2014 16:40:26 +0000 (18:40 +0200)]
Change ginMergeItemPointers to return a palloc'd array.

That seems nicer than making it the caller's responsibility to pass a
suitable-sized array. All the callers were just palloc'ing an array anyway.

10 years agoFix START_REPLICATION syntax in document.
Fujii Masao [Mon, 24 Mar 2014 10:23:32 +0000 (19:23 +0900)]
Fix START_REPLICATION syntax in document.

Enclose "TIMELINE tli" part with brackets because it's optional.

Backport to 9.3 where TIMELINE option was introduced.

Noted by Marko Tiikkaja

10 years agoRemove dead code and add comments.
Heikki Linnakangas [Mon, 24 Mar 2014 09:02:23 +0000 (11:02 +0200)]
Remove dead code and add comments.

'cbuffer' variable was left over from an earlier version of the patch to
rewrite the incomplete split handling.

10 years agoFix "the the" typos.
Heikki Linnakangas [Mon, 24 Mar 2014 06:42:13 +0000 (08:42 +0200)]
Fix "the the" typos.

Erik Rijkers

10 years agoDo jsonb regression test input in the conventional way.
Andrew Dunstan [Mon, 24 Mar 2014 00:18:06 +0000 (20:18 -0400)]
Do jsonb regression test input in the conventional way.

This should make the buildfarm happier.

10 years agoFix mis-spelling in jsonb docs.
Andrew Dunstan [Sun, 23 Mar 2014 22:25:16 +0000 (18:25 -0400)]
Fix mis-spelling in jsonb docs.

Per Thom Brown.

10 years agoIntroduce jsonb, a structured format for storing json.
Andrew Dunstan [Sun, 23 Mar 2014 20:40:19 +0000 (16:40 -0400)]
Introduce jsonb, a structured format for storing json.

The new format accepts exactly the same data as the json type. However, it is
stored in a format that does not require reparsing the orgiginal text in order
to process it, making it much more suitable for indexing and other operations.
Insignificant whitespace is discarded, and the order of object keys is not
preserved. Neither are duplicate object keys kept - the later value for a given
key is the only one stored.

The new type has all the functions and operators that the json type has,
with the exception of the json generation functions (to_json, json_agg etc.)
and with identical semantics. In addition, there are operator classes for
hash and btree indexing, and two classes for GIN indexing, that have no
equivalent in the json type.

This feature grew out of previous work by Oleg Bartunov and Teodor Sigaev, which
was intended to provide similar facilities to a nested hstore type, but which
in the end proved to have some significant compatibility issues.

Authors: Oleg Bartunov,  Teodor Sigaev, Peter Geoghegan and Andrew Dunstan.
Review: Andres Freund

10 years agoDon't test xmin/xmax columns of a postgres_fdw foreign table.
Noah Misch [Sun, 23 Mar 2014 07:48:17 +0000 (03:48 -0400)]
Don't test xmin/xmax columns of a postgres_fdw foreign table.

Their values are unspecified and system-dependent.

Per buildfarm member kouprey.

10 years agoOffer triggers on foreign tables.
Noah Misch [Sun, 23 Mar 2014 06:16:34 +0000 (02:16 -0400)]
Offer triggers on foreign tables.

This covers all the SQL-standard trigger types supported for regular
tables; it does not cover constraint triggers.  The approach for
acquiring the old row mirrors that for view INSTEAD OF triggers.  For
AFTER ROW triggers, we spool the foreign tuples to a tuplestore.

This changes the FDW API contract; when deciding which columns to
populate in the slot returned from data modification callbacks, writable
FDWs will need to check for AFTER ROW triggers in addition to checking
for a RETURNING clause.

In support of the feature addition, refactor the TriggerFlags bits and
the assembly of old tuples in ModifyTable.

Ronan Dunklau, reviewed by KaiGai Kohei; some additional hacking by me.

10 years agoImprove comments about AfterTriggerBeginQuery() query level usage.
Noah Misch [Sun, 23 Mar 2014 06:15:52 +0000 (02:15 -0400)]
Improve comments about AfterTriggerBeginQuery() query level usage.

10 years agoAddress ccvalid/ccnoinherit in TupleDesc support functions.
Noah Misch [Sun, 23 Mar 2014 06:13:43 +0000 (02:13 -0400)]
Address ccvalid/ccnoinherit in TupleDesc support functions.

equalTupleDescs() neglected both of these ConstrCheck fields, and
CreateTupleDescCopyConstr() neglected ccnoinherit.  At this time, the
only known behavior defect resulting from these omissions is constraint
exclusion disregarding a CHECK constraint validated by an ALTER TABLE
VALIDATE CONSTRAINT statement issued earlier in the same transaction.
Back-patch to 9.2, where these fields were introduced.

10 years agoFix thinkos in GinLogicValue enum.
Heikki Linnakangas [Fri, 21 Mar 2014 22:41:37 +0000 (23:41 +0100)]
Fix thinkos in GinLogicValue enum.

It was incorrectly declared as global variable, not an enum type, and
the comments for GIN_FALSE and GIN_TRUE were backwards.

10 years agoFix build with LWLOCK_STATS or dtrace.
Heikki Linnakangas [Fri, 21 Mar 2014 22:11:24 +0000 (23:11 +0100)]
Fix build with LWLOCK_STATS or dtrace.

Also fix the name of the dtrace probe for LWLockAcquireOrWait(). The
function was renamed from LWLockWaitUntilFree to LWLockAqcuireOrWait, but
the dtrace probe was neglected.

Pointed out by Andres Freund and the buildfarm.

10 years agoRemove MinGW readdir/errno bug workaround fixed on 2003-10-10
Bruce Momjian [Fri, 21 Mar 2014 17:47:37 +0000 (13:47 -0400)]
Remove MinGW readdir/errno bug workaround fixed on 2003-10-10

10 years agoProperly check for readdir/closedir() failures
Bruce Momjian [Fri, 21 Mar 2014 17:45:11 +0000 (13:45 -0400)]
Properly check for readdir/closedir() failures

Clear errno before calling readdir() and handle old MinGW errno bug
while adding full test coverage for readdir/closedir failures.

Backpatch through 8.4.

10 years agoReplace the XLogInsert slots with regular LWLocks.
Heikki Linnakangas [Fri, 21 Mar 2014 14:06:08 +0000 (15:06 +0100)]
Replace the XLogInsert slots with regular LWLocks.

The special feature the XLogInsert slots had over regular LWLocks is the
insertingAt value that was updated atomically with releasing backends
waiting on it. Add new functions to the LWLock API to do that, and replace
the slots with LWLocks. This reduces the amount of duplicated code.
(There's still some duplication, but at least it's all in lwlock.c now.)

Reviewed by Andres Freund.

10 years agoAgain fix initialization of auto-tuned effective_cache_size.
Tom Lane [Thu, 20 Mar 2014 16:58:13 +0000 (12:58 -0400)]
Again fix initialization of auto-tuned effective_cache_size.

The previous method was overly complex and underly correct; in particular,
by assigning the default value with PGC_S_OVERRIDE, it prevented later
attempts to change the setting in postgresql.conf, as noted by Jeff Janes.
We should just assign the default value with source PGC_S_DYNAMIC_DEFAULT,
which will have the desired priority relative to the boot_val as well as
user-set values.

There is still a gap in this method: if there's an explicit assignment of
effective_cache_size = -1 in the postgresql.conf file, and that assignment
appears before shared_buffers is assigned, the code will substitute 4 times
the bootstrap default for shared_buffers, and that value will then persist
(since it will have source PGC_S_FILE).  I don't see any very nice way
to avoid that though, and it's not a case to be expected in practice.
The existing comments in guc-file.l look forward to a redesign of the
DYNAMIC_DEFAULT mechanism; if that ever happens, we should consider this
case as one of the things we'd like to improve.

10 years agolibpq: pass a memory allocation failure error up to PQconndefaults()
Bruce Momjian [Thu, 20 Mar 2014 15:48:31 +0000 (11:48 -0400)]
libpq:  pass a memory allocation failure error up to PQconndefaults()

Previously user name memory allocation failures were ignored and the
default user name set to NULL.

10 years agotest_shm_mq: Improve regression tests.
Robert Haas [Thu, 20 Mar 2014 12:42:53 +0000 (08:42 -0400)]
test_shm_mq: Improve regression tests.

Per discussion with Tom Lane.

10 years agoSetup error context callback for transaction lock waits
Alvaro Herrera [Wed, 19 Mar 2014 18:10:36 +0000 (15:10 -0300)]
Setup error context callback for transaction lock waits

With this in place, a session blocking behind another one because of
tuple locks will get a context line mentioning the relation name, tuple
TID, and operation being done on tuple.  For example:

LOG:  process 11367 still waiting for ShareLock on transaction 717 after 1000.108 ms
DETAIL:  Process holding the lock: 11366. Wait queue: 11367.
CONTEXT:  while updating tuple (0,2) in relation "foo"
STATEMENT:  UPDATE foo SET value = 3;

Most usefully, the new line is displayed by log entries due to
log_lock_waits, although of course it will be printed by any other log
message as well.

Author: Christian Kruse, some tweaks by Álvaro Herrera
Reviewed-by: Amit Kapila, Andres Freund, Tom Lane, Robert Haas
10 years agoFix memory leak during regular expression execution.
Tom Lane [Wed, 19 Mar 2014 15:09:24 +0000 (11:09 -0400)]
Fix memory leak during regular expression execution.

For a regex containing backrefs, pg_regexec() might fail to free all the
sub-DFAs that were created during execution, resulting in a permanent
(session lifespan) memory leak.  Problem was introduced by me in commit
587359479acbbdc95c8e37da40707e37097423f5.  Per report from Sandro Santilli;
diagnosis by Greg Stark.

10 years agoSome minor improvements to logical decoding document.
Fujii Masao [Wed, 19 Mar 2014 13:13:05 +0000 (22:13 +0900)]
Some minor improvements to logical decoding document.

Also improve help message in pg_recvlogical.

10 years agoFix compilation of pg_xlogdump, now that rm_safe_restartpoint is no more.
Heikki Linnakangas [Tue, 18 Mar 2014 20:23:00 +0000 (22:23 +0200)]
Fix compilation of pg_xlogdump, now that rm_safe_restartpoint is no more.

Oops. Pointed out by Andres Freund.

10 years agoRemove rm_safe_restartpoint machinery.
Heikki Linnakangas [Tue, 18 Mar 2014 20:06:59 +0000 (22:06 +0200)]
Remove rm_safe_restartpoint machinery.

It is no longer used, none of the resource managers have multi-record
actions that would make it unsafe to perform a restartpoint.

Also don't allow rm_cleanup to write WAL records, it's also no longer
required. Move the call to rm_cleanup routines to make it more symmetric
with rm_startup.

10 years agoFix misc typos in comments.
Heikki Linnakangas [Tue, 18 Mar 2014 19:03:17 +0000 (21:03 +0200)]
Fix misc typos in comments.

10 years agoLogical decoding documentation corrections.
Robert Haas [Tue, 18 Mar 2014 18:57:49 +0000 (14:57 -0400)]
Logical decoding documentation corrections.

Thom Brown

10 years agoFix uninitialized variable.
Robert Haas [Tue, 18 Mar 2014 18:54:00 +0000 (14:54 -0400)]
Fix uninitialized variable.

Report from Andres Freund, but not his fix.

10 years agoMake the handling of interrupted B-tree page splits more robust.
Heikki Linnakangas [Tue, 18 Mar 2014 18:12:58 +0000 (20:12 +0200)]
Make the handling of interrupted B-tree page splits more robust.

Splitting a page consists of two separate steps: splitting the child page,
and inserting the downlink for the new right page to the parent. Previously,
we handled the case that you crash in between those steps with a cleanup
routine after the WAL recovery had finished, which finished the incomplete
split. However, that doesn't help if the page split is interrupted but the
database doesn't crash, so that you don't perform WAL recovery. That could
happen for example if you run out of disk space.

Remove the end-of-recovery cleanup step. Instead, when a page is split, the
left page is marked with a new INCOMPLETE_SPLIT flag, and when the downlink
is inserted to the parent, the flag is cleared again. If an insertion sees
a page with the flag set, it knows that the split was interrupted for some
reason, and inserts the missing downlink before proceeding.

I used the same approach to fix GIN and GiST split algorithms earlier. This
was the last WAL cleanup routine, so we could get rid of that whole
machinery now, but I'll leave that for a separate patch.

Reviewed by Peter Geoghegan.

10 years agoFix some remaining int64 vestiges in contrib/test_shm_mq.
Tom Lane [Tue, 18 Mar 2014 18:26:44 +0000 (14:26 -0400)]
Fix some remaining int64 vestiges in contrib/test_shm_mq.

Andres Freund and Tom Lane

10 years agotest_shm_mq: Use Size rather than uint64.
Robert Haas [Tue, 18 Mar 2014 17:30:19 +0000 (13:30 -0400)]
test_shm_mq: Use Size rather than uint64.

Commit 3bd261ca18c67eafe18088e58fab511e3b965418 updated the API but
neglected to make the corresponding edits here.

Per Tom Lane and the buildfarm.

10 years agoDocumentation for logical decoding.
Robert Haas [Tue, 18 Mar 2014 17:20:01 +0000 (13:20 -0400)]
Documentation for logical decoding.

Craig Ringer, Andres Freund, Christian Kruse, with edits by me.

10 years agoAdd pg_recvlogical, a tool to receive data logical decoding data.
Robert Haas [Tue, 18 Mar 2014 16:19:57 +0000 (12:19 -0400)]
Add pg_recvlogical, a tool to receive data logical decoding data.

This is fairly basic at the moment, but it's at least useful for
testing and debugging, and possibly more.

Andres Freund

10 years agoRewrite comment for shm_mq_receive_bytes.
Robert Haas [Tue, 18 Mar 2014 15:51:51 +0000 (11:51 -0400)]
Rewrite comment for shm_mq_receive_bytes.

The comment and the code diverged at some point before the initial
commit of this feature, and I failed to notice.

Noted by Tom Lane.

10 years agoFix relcache reference leak in refresh_by_match_merge().
Tom Lane [Tue, 18 Mar 2014 15:36:45 +0000 (11:36 -0400)]
Fix relcache reference leak in refresh_by_match_merge().

One path through the loop over indexes forgot to do index_close().  Rather
than adding a fourth call, restructure slightly so that there's only one.

In passing, get rid of an unnecessary syscache lookup: the pg_index struct
for the index is already available from its relcache entry.

Per report from YAMAMOTO Takashi, though this is a bit different from his
suggested patch.  This is new code in HEAD, so no need for back-patch.

10 years agoImprove shm_mq portability around MAXIMUM_ALIGNOF and sizeof(Size).
Robert Haas [Tue, 18 Mar 2014 15:19:13 +0000 (11:19 -0400)]
Improve shm_mq portability around MAXIMUM_ALIGNOF and sizeof(Size).

Revise the original decision to expose a uint64-based interface and
use Size everywhere possible.  Avoid assuming that MAXIMUM_ALIGNOF is
8, or making any assumption about the relationship between that value
and sizeof(Size).  If MAXIMUM_ALIGNOF is bigger, we'll now insert
padding after the length word; if it's smaller, we are now prepared
to read and write the length word in chunks.

Per discussion with Tom Lane.

10 years agoFix pg_dumpall option parsing: -i doesn't take an argument.
Tom Lane [Tue, 18 Mar 2014 14:38:25 +0000 (10:38 -0400)]
Fix pg_dumpall option parsing: -i doesn't take an argument.

This used to work properly, but got fat-fingered in commit
3dee636e0404885d07885d41c0d70e50c784f324.  Per bug #9620 from
Nicolas Payart.

10 years agoFix help message and document in pg_receivexlog.
Fujii Masao [Tue, 18 Mar 2014 12:15:45 +0000 (21:15 +0900)]
Fix help message and document in pg_receivexlog.

Add SLOTNAME placeholder to --slot option in help message and
document.

10 years agoMake it easy to detach completely from shared memory.
Robert Haas [Tue, 18 Mar 2014 11:58:53 +0000 (07:58 -0400)]
Make it easy to detach completely from shared memory.

The new function dsm_detach_all() can be used either by postmaster
children that don't wish to take any risk of accidentally corrupting
shared memory; or by forked children of regular backends with
the same need.  This patch also updates the postmaster children that
already do PGSharedMemoryDetach() to do dsm_detach_all() as well.

Per discussion with Tom Lane.

10 years agoRelease notes for 9.3.4, 9.2.8, 9.1.13, 9.0.17, 8.4.21.
Tom Lane [Mon, 17 Mar 2014 19:28:22 +0000 (15:28 -0400)]
Release notes for 9.3.4, 9.2.8, 9.1.13, 9.0.17, 8.4.21.

10 years agoDuring index build, check and elog (not just Assert) for broken HOT chain.
Tom Lane [Mon, 17 Mar 2014 16:36:11 +0000 (12:36 -0400)]
During index build, check and elog (not just Assert) for broken HOT chain.

The recently-fixed bug in WAL replay could result in not finding a parent
tuple for a heap-only tuple.  The existing code would either Assert or
generate an invalid index entry, neither of which is desirable.  Throw a
regular error instead.

10 years agoFix thinko: have trueTriConsistentFn return GIN_TRUE.
Heikki Linnakangas [Mon, 17 Mar 2014 15:18:40 +0000 (17:18 +0200)]
Fix thinko: have trueTriConsistentFn return GIN_TRUE.

While we're at it, also improve comments in ginlogic.c.

10 years agoFix typos in comments.
Fujii Masao [Mon, 17 Mar 2014 11:47:28 +0000 (20:47 +0900)]
Fix typos in comments.

Thom Brown

10 years agoFix bug in clean shutdown of walsender that pg_receiving is connecting to.
Fujii Masao [Mon, 17 Mar 2014 11:37:50 +0000 (20:37 +0900)]
Fix bug in clean shutdown of walsender that pg_receiving is connecting to.

On clean shutdown, walsender waits for all WAL to be replicated to a standby,
and exits. It determined whether that replication had been completed by
checking whether its sent location had been equal to a standby's flush
location. Unfortunately this condition never becomes true when the standby
such as pg_receivexlog which always returns an invalid flush location is
connecting to walsender, and then walsender waits forever.

This commit changes walsender so that it just checks a standby's write
location if a flush location is invalid.

Back-patch to 9.1 where enough infrastructure for this exists.

10 years agoFix small typo in comment
Magnus Hagander [Mon, 17 Mar 2014 08:09:21 +0000 (09:09 +0100)]
Fix small typo in comment

Michael Paquier

10 years agoplperl: Fix memory leak in hek2cstr
Alvaro Herrera [Mon, 17 Mar 2014 02:22:21 +0000 (23:22 -0300)]
plperl: Fix memory leak in hek2cstr

Backpatch all the way back to 9.1, where it was introduced by commit
50d89d42.

Reported by Sergey Burladyan in #9223
Author: Alex Hunsaker

10 years agoFix unportable shell-script syntax in pg_upgrade's test.sh.
Tom Lane [Mon, 17 Mar 2014 01:55:02 +0000 (21:55 -0400)]
Fix unportable shell-script syntax in pg_upgrade's test.sh.

I discovered the hard way that on some old shells, the locution
    FOO=""   unset FOO
does not behave the same as
    FOO="";  unset FOO
and in fact leaves FOO set to an empty string.  test.sh was inconsistently
spelling it different ways on adjacent lines.

This got broken relatively recently, in commit c737a2e56, so the lack of
field reports to date doesn't represent a lot of evidence that the problem
is rare.