]> granicus.if.org Git - postgresql/log
postgresql
8 years agoAdd new function planstate_tree_walker.
Robert Haas [Thu, 17 Sep 2015 15:24:49 +0000 (11:24 -0400)]
Add new function planstate_tree_walker.

ExplainPreScanNode knows how to iterate over a generic tree of plan
states; factor that logic out into a separate walker function so that
other code, such as upcoming patches for parallel query, can also use
it.

Patch by me, reviewed by Tom Lane.

8 years agoLet compiler handle size calculation of bool types.
Michael Meskes [Thu, 17 Sep 2015 13:41:04 +0000 (15:41 +0200)]
Let compiler handle size calculation of bool types.

Back in the day this did not work, but modern compilers should handle it themselves.

8 years agoFix bug introduced by microvacuum for GiST
Teodor Sigaev [Thu, 17 Sep 2015 11:22:37 +0000 (14:22 +0300)]
Fix bug introduced by microvacuum for GiST

Commit 013ebc0a7b7ea9c1b1ab7a3d4dd75ea121ea8ba7 introduces microvacuum for
GiST, deletetion of tuple marked LP_DEAD uses IndexPageMultiDelete while
recovery code uses IndexPageTupleDelete in loop. This causes a difference
in offset numbers of tuples to delete. Patch introduces usage of
IndexPageMultiDelete in GiST except gistplacetopage() where only one tuple is
deleted at once. That also slightly improve performance, because
IndexPageMultiDelete is more effective.

Patch changes WAL format, so bump wal page magic.

Bug report from Jeff Janes
Diagnostic and patch by Anastasia Lubennikova and me

8 years agoDetermine whether it's safe to attempt a parallel plan for a query.
Robert Haas [Wed, 16 Sep 2015 19:38:47 +0000 (15:38 -0400)]
Determine whether it's safe to attempt a parallel plan for a query.

Commit 924bcf4f16d54c55310b28f77686608684734f42 introduced a framework
for parallel computation in PostgreSQL that makes most but not all
built-in functions safe to execute in parallel mode.  In order to have
parallel query, we'll need to be able to determine whether that query
contains functions (either built-in or user-defined) that cannot be
safely executed in parallel mode.  This requires those functions to be
labeled, so this patch introduces an infrastructure for that.  Some
functions currently labeled as safe may need to be revised depending on
how pending issues related to heavyweight locking under paralllelism
are resolved.

Parallel plans can't be used except for the case where the query will
run to completion.  If portal execution were suspended, the parallel
mode restrictions would need to remain in effect during that time, but
that might make other queries fail.  Therefore, this patch introduces
a framework that enables consideration of parallel plans only when it
is known that the plan will be run to completion.  This probably needs
some refinement; for example, at bind time, we do not know whether a
query run via the extended protocol will be execution to completion or
run with a limited fetch count.  Having the client indicate its
intentions at bind time would constitute a wire protocol break.  Some
contexts in which parallel mode would be safe are not adjusted by this
patch; the default is not to try parallel plans except from call sites
that have been updated to say that such plans are OK.

This commit doesn't introduce any parallel paths or plans; it just
provides a way to determine whether they could potentially be used.
I'm committing it on the theory that the remaining parallel sequential
scan patches will also get committed to this release, hopefully in the
not-too-distant future.

Robert Haas and Amit Kapila.  Reviewed (in earlier versions) by Noah
Misch.

8 years agoSync regex code with Tcl 8.6.4.
Tom Lane [Wed, 16 Sep 2015 19:25:25 +0000 (15:25 -0400)]
Sync regex code with Tcl 8.6.4.

Sync our regex code with upstream changes since last time we did this,
which was Tcl 8.5.11 (see commit 08fd6ff37f71485e2fc04bc6ce07d2a483c36702).

The only functional change here is to disbelieve that an octal escape is
three digits long if it would exceed \377.  That's a bug fix, but it's
a minor one and could change the interpretation of working regexes, so
don't back-patch.

In addition to that, s/INFINITY/DUPINF/ to eliminate the risk of collisions
with <math.h>'s macro, and s/LOCAL/NOPROP/ because that also seems like
an unnecessarily collision-prone macro name.

There were some other cosmetic changes in their copy that I did not adopt,
notably a rather half-hearted attempt at renaming some of the C functions
in a more verbose style.  (I'm not necessarily against the concept, but
renaming just a few functions in the package is not an improvement.)

8 years agoFix documentation of regular expression character-entry escapes.
Tom Lane [Wed, 16 Sep 2015 18:50:12 +0000 (14:50 -0400)]
Fix documentation of regular expression character-entry escapes.

The docs claimed that \uhhhh would be interpreted as a Unicode value
regardless of the database encoding, but it's never been implemented
that way: \uhhhh and \xhhhh actually mean exactly the same thing, namely
the character that pg_mb2wchar translates to 0xhhhh.  Moreover we were
falsely dismissive of the usefulness of Unicode code points above FFFF.
Fix that.

It's been like this for ages, so back-patch to all supported branches.

8 years agoDon't use "#" as an abbreviation for "number" in PL/Tcl error messages.
Tom Lane [Wed, 16 Sep 2015 16:08:57 +0000 (12:08 -0400)]
Don't use "#" as an abbreviation for "number" in PL/Tcl error messages.

Also, rewrite one error message to make it follow our message style
guidelines better.

Euler Taveira and Tom Lane

8 years agoRemove no-longer-used T_PrivGrantee node tag.
Tom Lane [Wed, 16 Sep 2015 14:48:11 +0000 (10:48 -0400)]
Remove no-longer-used T_PrivGrantee node tag.

Oversight in commit 31eae6028eca4365e7165f5f33fee1ed0486aee0, which
replaced PrivGrantee nodes with RoleSpec nodes.  Spotted by Yugo Nagata.

8 years agopgbench progress with timestamp
Teodor Sigaev [Wed, 16 Sep 2015 14:24:53 +0000 (17:24 +0300)]
pgbench progress with timestamp

This patch adds an option to replace the "time since pgbench run
started" with a Unix epoch timestamp in the progress report so that,
for instance, it is easier to compare timelines with pgsql log

Fabien COELHO <coelho@cri.ensmp.fr>

8 years agoReview program help output for wording and formatting
Peter Eisentraut [Wed, 16 Sep 2015 04:37:39 +0000 (00:37 -0400)]
Review program help output for wording and formatting

8 years agoEnforce ALL/SELECT policies in RETURNING for RLS
Stephen Frost [Tue, 15 Sep 2015 19:49:31 +0000 (15:49 -0400)]
Enforce ALL/SELECT policies in RETURNING for RLS

For the UPDATE/DELETE RETURNING case, filter the records which are not
visible to the user through ALL or SELECT policies from those considered
for the UPDATE or DELETE.  This is similar to how the GRANT system
works, which prevents RETURNING unless the caller has SELECT rights on
the relation.

Per discussion with Robert, Dean, Tom, and Kevin.

Back-patch to 9.5 where RLS was introduced.

8 years agoRLS refactoring
Stephen Frost [Tue, 15 Sep 2015 19:49:31 +0000 (15:49 -0400)]
RLS refactoring

This refactors rewrite/rowsecurity.c to simplify the handling of the
default deny case (reducing the number of places where we check for and
add the default deny policy from three to one) by splitting up the
retrival of the policies from the application of them.

This also allowed us to do away with the policy_id field.  A policy_name
field was added for WithCheckOption policies and is used in error
reporting, when available.

Patch by Dean Rasheed, with various mostly cosmetic changes by me.

Back-patch to 9.5 where RLS was introduced to avoid unnecessary
differences, since we're still in alpha, per discussion with Robert.

8 years agoFix whitespace
Peter Eisentraut [Tue, 15 Sep 2015 19:20:13 +0000 (15:20 -0400)]
Fix whitespace

8 years agoRevert "Fix an O(N^2) problem in foreign key references".
Tom Lane [Tue, 15 Sep 2015 15:08:56 +0000 (11:08 -0400)]
Revert "Fix an O(N^2) problem in foreign key references".

Commit 5ddc72887a012f6a8b85707ef27d85c274faf53d does not actually work
because it will happily blow away ri_constraint_cache entries that are
in active use in outer call levels.  In any case, it's a very ugly,
brute-force solution to the problem of limiting the cache size.
Revert until it can be redesigned.

8 years agoAdd POLICY to COMMENT documentation
Stephen Frost [Tue, 15 Sep 2015 14:56:29 +0000 (10:56 -0400)]
Add POLICY to COMMENT documentation

COMMENT supports POLICY but the documentation hadn't caught up with
that fact.

Patch by Charles Clavadetscher

Back-patch to 9.5 where POLICY was added.

8 years agoFix comment regarding the meaning of infinity for timeline history entry
Fujii Masao [Tue, 15 Sep 2015 14:38:01 +0000 (23:38 +0900)]
Fix comment regarding the meaning of infinity for timeline history entry

Michael Paquier

8 years agoImprove log messages related to tablespace_map file
Fujii Masao [Tue, 15 Sep 2015 14:21:51 +0000 (23:21 +0900)]
Improve log messages related to tablespace_map file

This patch changes the log message which is logged when the server
successfully renames backup_label file to *.old but fails to rename
tablespace_map file during the shutdown. Previously the WARNING
message "online backup mode was not canceled" was logged in that case.
However this message is confusing because the backup mode is treated
as canceled whenever backup_label is successfully renamed. So this
commit makes the server log the message "online backup mode canceled"
in that case.

Also this commit changes errdetail messages so that they follow the
error message style guide.

Back-patch to 9.5 where tablespace_map file is introduced.

Original patch by Amit Kapila, heavily modified by me.

8 years agoFix wrong comment in commit d02426029b133ee2bbe492a038642359bce3c527
Teodor Sigaev [Tue, 15 Sep 2015 06:33:22 +0000 (09:33 +0300)]
Fix wrong comment in commit d02426029b133ee2bbe492a038642359bce3c527

Per gripe from Robert Haas

8 years agoCheck existency of table/schema for -t/-n option (pg_dump/pg_restore)
Teodor Sigaev [Mon, 14 Sep 2015 13:19:49 +0000 (16:19 +0300)]
Check existency of table/schema for -t/-n option (pg_dump/pg_restore)

Patch provides command line option --strict-names which requires that at
least one table/schema should present for each -t/-n option.

Pavel Stehule <pavel.stehule@gmail.com>

8 years agoAdd noreturn attribute
Peter Eisentraut [Sun, 13 Sep 2015 22:47:56 +0000 (18:47 -0400)]
Add noreturn attribute

per gcc -Wsuggest-attribute=noreturn

8 years agoFix the fastpath rule for jsonb_concat with an empty operand.
Andrew Dunstan [Sun, 13 Sep 2015 21:06:45 +0000 (17:06 -0400)]
Fix the fastpath rule for jsonb_concat with an empty operand.

To prevent perverse results, we now only return the other operand if
it's not scalar, and if both operands are of the same kind (array or
object).

Original bug complaint and patch from Oskari Saarenmaa, extended by me
to cover the cases of different kinds of jsonb.

Backpatch to 9.5 where jsonb_concat was introduced.

8 years agodoc: Remove dead links
Peter Eisentraut [Sun, 13 Sep 2015 03:49:11 +0000 (23:49 -0400)]
doc: Remove dead links

The web pages of Andy Dong at Berkeley don't exist anymore, and he is no
longer there.

8 years agoFix typo in create_policy.sgml
Stephen Frost [Sat, 12 Sep 2015 21:17:00 +0000 (17:17 -0400)]
Fix typo in create_policy.sgml

WTIH -> WITH

Pointed out by Dmitriy Olshevskiy

Backpatch to 9.5 where create_policy.sgml was added.

8 years agoUpdate SQL features list
Peter Eisentraut [Sat, 12 Sep 2015 04:07:56 +0000 (00:07 -0400)]
Update SQL features list

8 years agoInstall lwlocknames.h even in vpath builds.
Robert Haas [Fri, 11 Sep 2015 20:45:41 +0000 (16:45 -0400)]
Install lwlocknames.h even in vpath builds.

Per buildfarm member crake.

8 years agopg_dump, pg_upgrade: allow postgres/template1 tablespace moves
Bruce Momjian [Fri, 11 Sep 2015 19:51:11 +0000 (15:51 -0400)]
pg_dump, pg_upgrade:  allow postgres/template1 tablespace moves

Modify pg_dump to restore postgres/template1 databases to non-default
tablespaces by switching out of the database to be moved, then switching
back.

Also, to fix potentially cases where the old/new tablespaces might not
match, fix pg_upgrade to process new/old tablespaces separately in all
cases.

Report by Marti Raudsepp

Patch by Marti Raudsepp, me

Backpatch through 9.0

8 years agoFix build problems in commit aa65de042f5828968f2f6cd65f45c543a40cc3e6.
Robert Haas [Fri, 11 Sep 2015 18:53:41 +0000 (14:53 -0400)]
Fix build problems in commit aa65de042f5828968f2f6cd65f45c543a40cc3e6.

The previous way didn't work for vpath builds, and make distprep was
busted too.

Reported off-list by Andres Freund.

8 years agoAdd missing ReleaseBuffer call in BRIN revmap code
Alvaro Herrera [Fri, 11 Sep 2015 18:29:46 +0000 (15:29 -0300)]
Add missing ReleaseBuffer call in BRIN revmap code

I think this particular branch is actually dead, but the analysis to
prove that is not trivial, so instead take the weasel way.

Reported by Jinyu Zhang
Backpatch to 9.5, where BRIN was introduced.

8 years agoFix an O(N^2) problem in foreign key references.
Kevin Grittner [Fri, 11 Sep 2015 18:06:51 +0000 (13:06 -0500)]
Fix an O(N^2) problem in foreign key references.

Commit 45ba424f improved foreign key lookups during bulk updates
when the FK value does not change.  When restoring a schema dump
from a database with many (say 100,000) foreign keys, this cache
would grow very big and every ALTER TABLE command was causing an
InvalidateConstraintCacheCallBack(), which uses a sequential hash
table scan.  This could cause a severe performance regression in
restoring a schema dump (including during pg_upgrade).

The patch uses a heuristic method of detecting when the hash table
should be destroyed and recreated.
InvalidateConstraintCacheCallBack() adds the current size of the
hash table to a counter.  When that sum reaches 1,000,000, the hash
table is flushed.  This fixes the regression without noticeable
harm to the bulk update use case.

Jan Wieck
Backpatch to 9.3 where the performance regression was introduced.

8 years agoWhen trace_lwlocks is used, identify individual lwlocks by name.
Robert Haas [Fri, 11 Sep 2015 17:58:28 +0000 (13:58 -0400)]
When trace_lwlocks is used, identify individual lwlocks by name.

Naming the individual lwlocks seems like something that may be useful
for other types of debugging, monitoring, or instrumentation output,
but this commit just implements it for the specific case of
trace_lwlocks.

Patch by me, reviewed by Amit Kapila and Kyotaro Horiguchi

8 years agoCorrect description of PageHeaderData layout in documentation
Fujii Masao [Fri, 11 Sep 2015 04:02:15 +0000 (13:02 +0900)]
Correct description of PageHeaderData layout in documentation

Back-patch to 9.3 where PageHeaderData layout was changed.

Michael Paquier

8 years agodoc: Spell checking
Peter Eisentraut [Fri, 11 Sep 2015 01:22:21 +0000 (21:22 -0400)]
doc: Spell checking

8 years agoFix setrefs.c comment properly.
Tom Lane [Thu, 10 Sep 2015 14:23:56 +0000 (10:23 -0400)]
Fix setrefs.c comment properly.

The "typo" alleged in commit 1e460d4bd was actually a comment that was
correct when written, but I missed updating it in commit b5282aa89.
Use a slightly less specific (and hopefully more future-proof) description
of what is collected.  Back-patch to 9.2 where that commit appeared, and
revert the comment to its then-entirely-correct state before that.

8 years agoFix typo in setrefs.c
Stephen Frost [Thu, 10 Sep 2015 13:22:03 +0000 (09:22 -0400)]
Fix typo in setrefs.c

We're adding OIDs, not TIDs, to invalItems.

Pointed out by Etsuro Fujita.

Back-patch to all supported branches.

8 years agoFix minor bug in regexp makesearch() function.
Tom Lane [Thu, 10 Sep 2015 00:14:58 +0000 (20:14 -0400)]
Fix minor bug in regexp makesearch() function.

The list-wrangling here was done wrong, allowing the same state to get
put into the list twice.  The following loop then would clone it twice.
The second clone would wind up with no inarcs, so that there was no
observable misbehavior AFAICT, but a useless state in the finished NFA
isn't an especially good thing.

8 years agoFix oversight in 013ebc0a7b7ea9c1b1ab7a3d4dd75ea121ea8ba7 commit
Teodor Sigaev [Wed, 9 Sep 2015 16:21:16 +0000 (19:21 +0300)]
Fix oversight in 013ebc0a7b7ea9c1b1ab7a3d4dd75ea121ea8ba7 commit

Declaration of varibale inside ÓÝ×Õ

8 years agoMicrovacuum for GIST
Teodor Sigaev [Wed, 9 Sep 2015 15:43:37 +0000 (18:43 +0300)]
Microvacuum for GIST

Mark index tuple as dead if it's pointed by kill_prior_tuple during
ordinary (search) scan and remove it during insert process if there is no
enough space for new tuple to insert. This improves select performance
because index will not return tuple marked as dead and improves insert
performance because it reduces number of page split.

Anastasia Lubennikova <a.lubennikova@postgrespro.ru> with
 minor editorialization by me

8 years agoRemove files signaling a standby promotion request at postmaster startup
Fujii Masao [Wed, 9 Sep 2015 13:51:44 +0000 (22:51 +0900)]
Remove files signaling a standby promotion request at postmaster startup

This commit makes postmaster forcibly remove the files signaling
a standby promotion request. Otherwise, the existence of those files
can trigger a promotion too early, whether a user wants that or not.

This removal of files is usually unnecessary because they can exist
only during a few moments during a standby promotion. However
there is a race condition: if pg_ctl promote is executed and creates
the files during a promotion, the files can stay around even after
the server is brought up to new master. Then, if new standby starts
by using the backup taken from that master, the files can exist
at the server startup and should be removed in order to avoid
an unexpected promotion.

Back-patch to 9.1 where promote signal file was introduced.

Problem reported by Feike Steenbergen.
Original patch by Michael Paquier, modified by me.

Discussion: 20150528100705.4686.91426@wrigleys.postgresql.org

8 years agoLock all relations referred to in updatable views
Stephen Frost [Tue, 8 Sep 2015 21:02:49 +0000 (17:02 -0400)]
Lock all relations referred to in updatable views

Even views considered "simple" enough to be automatically updatable may
have mulitple relations involved (eg: in a where clause).  We need to
make sure and lock those relations when rewriting the query.

Back-patch to 9.3 where updatable views were added.

Pointed out by Andres, patch thanks to Dean Rasheed.

8 years agopsql: Generic tab completion support for enum and bool GUCs.
Andres Freund [Tue, 8 Sep 2015 18:57:35 +0000 (20:57 +0200)]
psql: Generic tab completion support for enum and bool GUCs.

Author: Pavel Stehule
Reviewed-By: Andres Freund
Discussion: 5594FE7A.5050205@iki.fi

8 years agoAdd gin_fuzzy_search_limit to postgresql.conf.sample.
Fujii Masao [Tue, 8 Sep 2015 17:25:50 +0000 (02:25 +0900)]
Add gin_fuzzy_search_limit to postgresql.conf.sample.

This was forgotten in 8a3631f (commit that originally added the parameter)
and 0ca9907 (commit that added the documentation later that year).

Back-patch to all supported versions.

8 years agoImprove tab-completion for GRANT and REVOKE.
Fujii Masao [Tue, 8 Sep 2015 16:58:29 +0000 (01:58 +0900)]
Improve tab-completion for GRANT and REVOKE.

Thomas Munro, reviewed by Michael Paquier, modified by me.

8 years agoAllow per-tablespace effective_io_concurrency
Alvaro Herrera [Tue, 8 Sep 2015 15:51:42 +0000 (12:51 -0300)]
Allow per-tablespace effective_io_concurrency

Per discussion, nowadays it is possible to have tablespaces that have
wildly different I/O characteristics from others.  Setting different
effective_io_concurrency parameters for those has been measured to
improve performance.

Author: Julien Rouhaud
Reviewed by: Andres Freund

8 years agoFix error message wording in previous sslinfo commit
Alvaro Herrera [Tue, 8 Sep 2015 14:10:20 +0000 (11:10 -0300)]
Fix error message wording in previous sslinfo commit

8 years agocontrib/sslinfo: add ssl_extension_info SRF
Alvaro Herrera [Tue, 8 Sep 2015 00:24:17 +0000 (21:24 -0300)]
contrib/sslinfo: add ssl_extension_info SRF

This new function provides information about SSL extensions present in
the X509 certificate used for the current connection.

Extension version updated to version 1.1.

Author: Дмитрий Воронин (Dmitry Voronin)
Reviewed by: Michael Paquier, Heikki Linnakangas, Álvaro Herrera

8 years agoIn the pg_rewind test suite, receive WAL fully before promoting.
Noah Misch [Mon, 7 Sep 2015 23:01:00 +0000 (19:01 -0400)]
In the pg_rewind test suite, receive WAL fully before promoting.

If a transaction never reaches the standby, later tests find unexpected
cluster state.  A "tail-copy: query result matches" test failure has
been the usual symptom.  Among the buildfarm members having run this
test suite, most have exhibited that symptom at least once.  Back-patch
to 9.5, where pg_rewind was introduced.

Michael Paquier, reported by Christoph Berg.

8 years agoCoordinate log_line_prefix options 'm' and 'n' to share a timeval.
Jeff Davis [Mon, 7 Sep 2015 22:40:49 +0000 (15:40 -0700)]
Coordinate log_line_prefix options 'm' and 'n' to share a timeval.

Commit f828654e introduced the 'n' option, but it invoked
gettimeofday() independently of the 'm' option. If both options were
in use (or multiple 'n' options), or if 'n' was in use along with
csvlog, then the reported times could be different for the same log
message.

To fix, initialize a global variable with gettimeofday() once per log
message, and use that for both formats.

Don't bother coordinating the time for the 't' option, which has much
lower resolution.

Per complaint by Alvaro Herrera.

8 years agoAdd more sanity checks in contrib/sslinfo
Alvaro Herrera [Mon, 7 Sep 2015 22:18:29 +0000 (19:18 -0300)]
Add more sanity checks in contrib/sslinfo

We were missing a few return checks on OpenSSL calls.  Should be pretty
harmless, since we haven't seen any user reports about problems, and
this is not a high-traffic module anyway; still, a bug is a bug, so
backpatch this all the way back to 9.0.

Author: Michael Paquier, while reviewing another sslinfo patch

8 years agoAdd log_line_prefix option 'n' for Unix epoch.
Jeff Davis [Mon, 7 Sep 2015 20:46:31 +0000 (13:46 -0700)]
Add log_line_prefix option 'n' for Unix epoch.

Prints time as Unix epoch with milliseconds.

Tomas Vondra, reviewed by Fabien Coelho.

8 years agoChange type of DOW/DOY to UNITS
Greg Stark [Mon, 7 Sep 2015 12:35:09 +0000 (13:35 +0100)]
Change type of DOW/DOY to UNITS

8 years agoMake GIN's cleanup pending list process interruptable
Teodor Sigaev [Mon, 7 Sep 2015 14:16:29 +0000 (17:16 +0300)]
Make GIN's cleanup pending list process interruptable

Cleanup process could be called by ordinary insert/update and could take a lot
of time. Add vacuum_delay_point() to make this process interruptable. Under
vacuum this call will also throttle a vacuum process to decrease system load,
called from insert/update it will not throttle, and that reduces a latency.

Backpatch for all supported branches.

Jeff Janes <jeff.janes@gmail.com>

8 years agoAdd pages deleted from pending list to FSM
Teodor Sigaev [Mon, 7 Sep 2015 13:24:01 +0000 (16:24 +0300)]
Add pages deleted from pending list to FSM

Add pages deleted from GIN's pending list during cleanup to free space map
immediately. Clean up process could be initiated by ordinary insert but adding
page to FSM might occur only at vacuum. On some workload like never-vacuumed
insert-only tables it could cause a huge bloat.

Jeff Janes <jeff.janes@gmail.com>

8 years agoUpdate site address of Snowball project
Teodor Sigaev [Mon, 7 Sep 2015 12:20:45 +0000 (15:20 +0300)]
Update site address of Snowball project

8 years agoAdjust sepgsql regression output for recent error context change
Joe Conway [Sun, 6 Sep 2015 18:25:36 +0000 (11:25 -0700)]
Adjust sepgsql regression output for recent error context change

Recent commit 0426f349e changed handling of error context reports
in such a way to have a minor effect on the sepgsql regression
output. Adapt the expected output file to suit. Since that commit
was HEAD only, so is this one.

8 years agoSupport RADIUS passwords up to 128 characters
Magnus Hagander [Sun, 6 Sep 2015 12:26:33 +0000 (14:26 +0200)]
Support RADIUS passwords up to 128 characters

Previous limit was 16 characters, due to lack of support for multiple passes
of encryption.

Marko Tiikkaja

8 years agoAdd ability to reserve WAL upon slot creation via replication protocol.
Andres Freund [Sun, 6 Sep 2015 11:17:23 +0000 (13:17 +0200)]
Add ability to reserve WAL upon slot creation via replication protocol.

Since 6fcd885 it is possible to immediately reserve WAL when creating a
slot via pg_create_physical_replication_slot(). Extend the replication
protocol to allow that as well.

Although, in contrast to the SQL interface, it is possible to update the
reserved location via the replication interface, it is still useful
being able to reserve upon creation there. Otherwise the logic in
ReplicationSlotReserveWal() has to be repeated in slot employing
clients.

Author: Michael Paquier
Discussion: CAB7nPqT0Wc1W5mdYGeJ_wbutbwNN+3qgrFR64avXaQCiJMGaYA@mail.gmail.com

8 years agoMove DTK_ISODOW DTK_DOW and DTK_DOY to be type UNITS rather than
Greg Stark [Sun, 6 Sep 2015 01:04:37 +0000 (02:04 +0100)]
Move DTK_ISODOW DTK_DOW and DTK_DOY to be type UNITS rather than
RESERV. RESERV is meant for tokens like "now" and having them in that
category throws errors like these when used as an input date:

stark=# SELECT 'doy'::timestamptz;
ERROR:  unexpected dtype 33 while parsing timestamptz "doy"
LINE 1: SELECT 'doy'::timestamptz;
               ^
stark=# SELECT 'dow'::timestamptz;
ERROR:  unexpected dtype 32 while parsing timestamptz "dow"
LINE 1: SELECT 'dow'::timestamptz;
               ^

Found by LLVM's Libfuzzer

8 years agoFix CreateTableSpace() so it will compile without HAVE_SYMLINK.
Tom Lane [Sat, 5 Sep 2015 20:15:38 +0000 (16:15 -0400)]
Fix CreateTableSpace() so it will compile without HAVE_SYMLINK.

This has been broken since 9.3 (commit 82b1b213cad3a69c to be exact),
which suggests that nobody is any longer using a Windows build system that
doesn't provide a symlink emulation.  Still, it's wrong on its own terms,
so repair.

YUriy Zhuravlev

8 years agoRearrange the handling of error context reports.
Tom Lane [Sat, 5 Sep 2015 15:58:20 +0000 (11:58 -0400)]
Rearrange the handling of error context reports.

Remove the code in plpgsql that suppressed the innermost line of CONTEXT
for messages emitted by RAISE commands.  That was never more than a quick
backwards-compatibility hack, and it's pretty silly in cases where the
RAISE is nested in several levels of function.  What's more, it violated
our design theory that verbosity of error reports should be controlled
on the client side not the server side.

To alleviate the resulting noise increase, introduce a feature in libpq
and psql whereby the CONTEXT field of messages can be suppressed, either
always or only for non-error messages.  Printing CONTEXT for errors only
is now their default behavior.

The actual code changes here are pretty small, but the effects on the
regression test outputs are widespread.  I had to edit some of the
alternative expected outputs by hand; hopefully the buildfarm will soon
find anything I fat-fingered.

In passing, fix up (again) the output line counts in psql's various
help displays.  Add some commentary about how to verify them.

Pavel Stehule, reviewed by Petr Jelínek, Jeevan Chalke, and others

8 years agoFix misc typos.
Heikki Linnakangas [Sat, 5 Sep 2015 08:35:49 +0000 (11:35 +0300)]
Fix misc typos.

Oskari Saarenmaa. Backpatch to stable branches where applicable.

8 years agoFix brin index summarizing while vacuuming.
Tatsuo Ishii [Sat, 5 Sep 2015 00:19:25 +0000 (09:19 +0900)]
Fix brin index summarizing while vacuuming.

If the number of heap blocks is not multiples of pages per range, the
summarizing produces wrong summary information for the last brin index
tuple while vacuuming.

Problem reported by Tatsuo Ishii and fixed by Amit Langote.

Discussion at "[HACKERS] BRIN INDEX value (message id :20150903.174935.1946402199422994347.t-ishii@sraoss.co.jp)
Backpatched to 9.5 in which brin index was added.

8 years agoFix subtransaction cleanup after an outer-subtransaction portal fails.
Tom Lane [Fri, 4 Sep 2015 17:36:49 +0000 (13:36 -0400)]
Fix subtransaction cleanup after an outer-subtransaction portal fails.

Formerly, we treated only portals created in the current subtransaction as
having failed during subtransaction abort.  However, if the error occurred
while running a portal created in an outer subtransaction (ie, a cursor
declared before the last savepoint), that has to be considered broken too.

To allow reliable detection of which ones those are, add a bookkeeping
field to struct Portal that tracks the innermost subtransaction in which
each portal has actually been executed.  (Without this, we'd end up
failing portals containing functions that had called the subtransaction,
thereby breaking plpgsql exception blocks completely.)

In addition, when we fail an outer-subtransaction Portal, transfer its
resources into the subtransaction's resource owner, so that they're
released early in cleanup of the subxact.  This fixes a problem reported by
Jim Nasby in which a function executed in an outer-subtransaction cursor
could cause an Assert failure or crash by referencing a relation created
within the inner subtransaction.

The proximate cause of the Assert failure is that AtEOSubXact_RelationCache
assumed it could blow away a relcache entry without first checking that the
entry had zero refcount.  That was a bad idea on its own terms, so add such
a check there, and to the similar coding in AtEOXact_RelationCache.  This
provides an independent safety measure in case there are still ways to
provoke the situation despite the Portal-level changes.

This has been broken since subtransactions were invented, so back-patch
to all supported branches.

Tom Lane and Michael Paquier

8 years agoMake unaccent handle all diacritics known to Unicode, and expand ligatures correctly
Teodor Sigaev [Fri, 4 Sep 2015 09:51:53 +0000 (12:51 +0300)]
Make unaccent handle all diacritics known to Unicode, and expand ligatures correctly

Add Python script for buiding unaccent.rules from Unicode data. Don't
backpatch because unaccent changes may require tsvector/index
rebuild.

Thomas Munro <thomas.munro@enterprisedb.com>

8 years agoAssorted code review for recent ProcArrayLock patch.
Robert Haas [Thu, 3 Sep 2015 17:10:53 +0000 (13:10 -0400)]
Assorted code review for recent ProcArrayLock patch.

Post-commit review by Andres Freund discovered a couple of concurrency
bugs in the original patch: specifically, if the leader cleared a
follower's XID before it reached PGSemaphoreLock, the semaphore would be
left in the wrong state; and if another process did PGSemaphoreUnlock
for some unrelated reason, we might resume execution before the fact
that our XID was cleared was globally visible.

Also, improve the wording of some comments, rename nextClearXidElem
to firstClearXidElem in PROC_HDR for clarity, and drop some volatile
qualifiers that aren't necessary.

Amit Kapila, reviewed and slightly revised by me.

8 years agoDocument that max_worker_processes must be high enough in standby.
Fujii Masao [Thu, 3 Sep 2015 13:30:16 +0000 (22:30 +0900)]
Document that max_worker_processes must be high enough in standby.

The setting values of some parameters including max_worker_processes
must be equal to or higher than the values on the master. However,
previously max_worker_processes was not listed as such parameter
in the document. So this commit adds it to that list.

Back-patch to 9.4 where max_worker_processes was added.

8 years agoDisable fsync throughout TAP test suites.
Noah Misch [Thu, 3 Sep 2015 04:29:11 +0000 (00:29 -0400)]
Disable fsync throughout TAP test suites.

Most suites already did so via start_test_server(), but the pg_rewind,
pg_ctl and pg_controldata suites ran a postmaster or initdb with fsync
enabled.  This halves the pg_rewind suite's runtime on buildfarm member
tern.  It makes tern and that machine's other buildfarm members less
vulnerable to noise failures from postmaster startup overrunning the 60s
pg_ctl timeout.  Back-patch to 9.5, where pg_rewind was introduced.

8 years agoUpdate the SSL test suite for recent changes to TAP testing framework.
Robert Haas [Wed, 2 Sep 2015 20:21:38 +0000 (16:21 -0400)]
Update the SSL test suite for recent changes to TAP testing framework.

listen_addresses needs to be handled differently now, and so does
logging.

Michael Paquier

8 years agoAllow usage of huge maintenance_work_mem for GIN build.
Teodor Sigaev [Wed, 2 Sep 2015 17:08:58 +0000 (20:08 +0300)]
Allow usage of huge maintenance_work_mem for GIN build.

Currently, in-memory posting list during GIN build process is limited 1GB
because of using repalloc. The patch replaces call of repalloc to repalloc_huge.
It increases limit of posting list from 180 millions
(1GB / sizeof(ItemPointerData)) to 4 billions limited by maxcount/count fields
in GinEntryAccumulator and subsequent calls. Check added.

Also, fix accounting of allocatedMemory during build to prevent integer
overflow with maintenance_work_mem > 4GB.

Robert Abraham <robert.abraham86@googlemail.com> with additions by me

8 years agoDocument that PL/Python now returns floats using repr() not str().
Tom Lane [Tue, 1 Sep 2015 23:25:58 +0000 (19:25 -0400)]
Document that PL/Python now returns floats using repr() not str().

Commit 1ce7a57ca neglected to update the user-facing documentation,
which described the old behavior precisely.

8 years agoFlush to show results of TestLib.pm (TAP) test as we go.
Kevin Grittner [Tue, 1 Sep 2015 21:12:22 +0000 (16:12 -0500)]
Flush to show results of TestLib.pm (TAP) test as we go.

It appears that some attempt was made to do this using autocommit,
but it wasn't effective (at least on Ubuntu 14.04).

8 years agopg_upgrade docs: clarify rsync and move verification step
Bruce Momjian [Tue, 1 Sep 2015 20:42:43 +0000 (16:42 -0400)]
pg_upgrade docs:  clarify rsync and move verification step

These are adjustments based on someone using the new standby upgrade
steps.

Report by Andy Colson

Backpatch through 9.5

8 years agoAllow notifications to bgworkers without database connections.
Robert Haas [Tue, 1 Sep 2015 19:30:19 +0000 (15:30 -0400)]
Allow notifications to bgworkers without database connections.

Previously, if one background worker registered another background
worker and set bgw_notify_pid while for the second background worker,
it would not receive notifications from the postmaster unless, at the
time the "parent" was registered, BGWORKER_BACKEND_DATABASE_CONNECTION
was set.

To fix, instead instead of including only those background workers that
requested database connections in the postmater's BackendList, include
them all.  There doesn't seem to be any reason not do this, and indeed
it removes a significant amount of duplicated code.  The other option
is to make PostmasterMarkPIDForWorkerNotify look at BackgroundWorkerList
in addition to BackendList, but that adds more code duplication instead
of getting rid of it.

Patch by me.  Review and testing by Ashutosh Bapat.

8 years agoUse <substeps> in pg_upgrade's procedure
Alvaro Herrera [Tue, 1 Sep 2015 17:58:28 +0000 (14:58 -0300)]
Use <substeps> in pg_upgrade's procedure

For clarity, so that the substeps are not numbered identically to the
outer procedure's steps.

Per report from Andy Colson in
http://www.postgresql.org/message-id/55D789B5.7040308@squeakycode.net

8 years agoClean up icc + ia64 situation.
Tom Lane [Mon, 31 Aug 2015 22:10:04 +0000 (18:10 -0400)]
Clean up icc + ia64 situation.

Some googling turned up multiple sources saying that older versions of icc
do not accept gcc-compatible asm blocks on IA64, though asm does work on
x86[_64].  This is apparently fixed as of icc version 12.0 or so, but that
doesn't help us much; if we have to carry the extra implementation anyway,
we may as well just use it for icc rather than add a compiler version test.

Hence, revert commit 2c713d6ea29c91cd2cbd92fa801a61e55ea2a3c4 (though I
separated the icc code from the gcc code completely, producing what seems
cleaner code).  Document the state of affairs more explicitly, both in
s_lock.h and postgres.c, and make some cosmetic adjustments around the
IA64 code in s_lock.h.

8 years agodocs: remove outdated note about unique indexes
Bruce Momjian [Mon, 31 Aug 2015 21:05:23 +0000 (17:05 -0400)]
docs:  remove outdated note about unique indexes

Patch by Josh Kupershmidt

Backpatch through 9.5

8 years agoAllow icc to use the same atomics infrastructure as gcc.
Tom Lane [Mon, 31 Aug 2015 20:30:12 +0000 (16:30 -0400)]
Allow icc to use the same atomics infrastructure as gcc.

The atomics headers were written under the impression that icc doesn't
handle gcc-style asm blocks, but this is demonstrably false on x86_[64],
because s_lock.h has done it that way for more than a decade.  (The jury is
still out on whether this also works on ia64, so I'm leaving ia64-related
code alone for the moment.)  Treat gcc and icc the same in these headers.
This is less code and it should improve the results for icc, because we
hadn't gotten around to providing icc-specific implementations for most
of the atomics.

8 years agoActually, it's not that hard to merge the Windows pqsignal code ...
Tom Lane [Mon, 31 Aug 2015 19:52:56 +0000 (15:52 -0400)]
Actually, it's not that hard to merge the Windows pqsignal code ...

... just need to typedef sigset_t and provide sigemptyset/sigfillset,
which are easy enough.

8 years agoRemove theoretically-unnecessary special case for icc.
Tom Lane [Mon, 31 Aug 2015 18:43:10 +0000 (14:43 -0400)]
Remove theoretically-unnecessary special case for icc.

Intel's icc is generally able to swallow asm blocks written for gcc.
We have a few places that don't seem to know that, though.  Experiment
with removing the special case for icc in ia64_get_bsp(); if the buildfarm
likes this, I'll try more cleanup.  This is a good test case because it
involves a "stop" notation that seems like it might not be very portable.

8 years agoRemove support for Unix systems without the POSIX signal APIs.
Tom Lane [Mon, 31 Aug 2015 16:55:59 +0000 (12:55 -0400)]
Remove support for Unix systems without the POSIX signal APIs.

Remove configure's checks for HAVE_POSIX_SIGNALS, HAVE_SIGPROCMASK, and
HAVE_SIGSETJMP.  These APIs are required by the Single Unix Spec v2
(POSIX 1997), which we generally consider to define our minimum required
set of Unix APIs.  Moreover, no buildfarm member has reported not having
them since 2012 or before, which means that even if the code is still live
somewhere, it's untested --- and we've made plenty of signal-handling
changes of late.  So just take these APIs as given and save the cycles for
configure probes for them.

However, we can't remove as much C code as I'd hoped, because the Windows
port evidently still uses the non-POSIX code paths for signal masking.
Since we're largely emulating these BSD-style APIs for Windows anyway, it
might be a good thing to switch over to POSIX-like notation and thereby
remove a few more #ifdefs.  But I'm not in a position to code or test that.
In the meantime, we can at least make things a bit more transparent by
testing for WIN32 explicitly in these places.

8 years agopsql: print longtable as a possible \pset option
Bruce Momjian [Mon, 31 Aug 2015 16:24:16 +0000 (12:24 -0400)]
psql:  print longtable as a possible \pset option

For some reason this message was not updated when the longtable option
was added.

Backpatch through 9.3

8 years agoSmall grammar fix
Magnus Hagander [Mon, 31 Aug 2015 12:07:17 +0000 (14:07 +0200)]
Small grammar fix

Josh Kupershmidt

8 years agoRemove long-dead support for platforms without sig_atomic_t.
Tom Lane [Mon, 31 Aug 2015 05:36:46 +0000 (01:36 -0400)]
Remove long-dead support for platforms without sig_atomic_t.

C89 requires <signal.h> to define sig_atomic_t, and there is no evidence
in the buildfarm that any supported platforms don't comply.  Remove the
configure test to stop wasting build cycles on a purely historical issue.
(Once upon a time, we cared about supporting C89-compliant compilers on
machines with pre-C89 system headers, but that use-case has been dead for
quite a few years.)

I have some other fixes planned in this area, but let's start with this
to see if the buildfarm produces any surprising results.

8 years agoFix sepgsql regression tests.
Joe Conway [Sun, 30 Aug 2015 18:09:05 +0000 (11:09 -0700)]
Fix sepgsql regression tests.

The regression tests for sepgsql were broken by changes in the
base distro as-shipped policies. Specifically, definition of
unconfined_t in the system default policy was changed to bypass
multi-category rules, which the regression test depended on.
Fix that by defining a custom privileged domain
(sepgsql_regtest_superuser_t) and using it instead of system's
unconfined_t domain. The new sepgsql_regtest_superuser_t domain
performs almost like the current unconfined_t, but restricted by
multi-category policy as the traditional unconfined_t was.

The custom policy module is a self defined domain, and so should not
be affected by related future system policy changes. However, it still
uses the unconfined_u:unconfined_r pair for selinux-user and role.
Those definitions have not been changed for several years and seem
less risky to rely on than the unconfined_t domain. Additionally, if
we define custom user/role, they would need to be manually defined
at the operating system level, adding more complexity to an already
non-standard and complex regression test.

Back-patch to 9.3. The regression tests will need more work before
working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
on libselinux versions that are only available on newer distros with
the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
fine with the older distros with original policy set (e.g. RHEL 6.x),
and on which the existing regression tests work fine. We might want
eventually change 9.1 sepgsql regression tests to be more independent
from the underlying OS policies, however more work will be needed to
make that happen and it is not clear that it is worth the effort.

Kohei KaiGai with review by Adam Brightwell and me, commentary by
Stephen, Alvaro, Tom, Robert, and others.

9 years agoFix s_lock.h PPC assembly code to be compatible with native AIX assembler.
Tom Lane [Sat, 29 Aug 2015 20:09:25 +0000 (16:09 -0400)]
Fix s_lock.h PPC assembly code to be compatible with native AIX assembler.

On recent AIX it's necessary to configure gcc to use the native assembler
(because the GNU assembler hasn't been updated to handle AIX 6+).  This
caused PG builds to fail with assembler syntax errors, because we'd try
to compile s_lock.h's gcc asm fragment for PPC, and that assembly code
relied on GNU-style local labels.  We can't substitute normal labels
because it would fail in any file containing more than one inlined use of
tas().  Fortunately, that code is stable enough, and the PPC ISA is simple
enough, that it doesn't seem like too much of a maintenance burden to just
hand-code the branch offsets, removing the need for any labels.

Note that the AIX assembler only accepts "$" for the location counter
pseudo-symbol.  The usual GNU convention is "."; but it appears that all
versions of gas for PPC also accept "$", so in theory this patch will not
break any other PPC platforms.

This has been reported by a few people, but Steve Underwood gets the credit
for being the first to pursue the problem far enough to understand why it
was failing.  Thanks also to Noah Misch for additional testing.

9 years agoEnsure locks are acquired on RLS-added relations
Stephen Frost [Fri, 28 Aug 2015 15:39:37 +0000 (11:39 -0400)]
Ensure locks are acquired on RLS-added relations

During fireRIRrules(), get_row_security_policies can add to
securityQuals and withCheckOptions.  Make sure to lock any relations
added at that point and before firing RIR rules on those expressions.

Back-patch to 9.5 where RLS was added.

9 years agoClarify what some historic terms in rewriteHandler.c mean.
Andres Freund [Fri, 28 Aug 2015 14:24:32 +0000 (16:24 +0200)]
Clarify what some historic terms in rewriteHandler.c mean.

Discussion: 20150827131352.GF2435@awork2.anarazel.de

9 years agoSimplify Perl chmod calls
Peter Eisentraut [Tue, 25 Aug 2015 13:58:49 +0000 (09:58 -0400)]
Simplify Perl chmod calls

The Perl chmod function already takes multiple file arguments, so we
don't need a separate looping function.

9 years agodblink docs: fix typo to use "connname" (3 n's), not "conname"
Bruce Momjian [Thu, 27 Aug 2015 17:43:10 +0000 (13:43 -0400)]
dblink docs:  fix typo to use "connname" (3 n's), not "conname"

This makes the parameter names match the documented prototype names.

Report by Erwin Brandstetter

Backpatch through 9.0

9 years agoSpeed up HeapTupleSatisfiesMVCC() by replacing the XID-in-progress test.
Tom Lane [Wed, 26 Aug 2015 22:18:57 +0000 (18:18 -0400)]
Speed up HeapTupleSatisfiesMVCC() by replacing the XID-in-progress test.

Rather than consulting TransactionIdIsInProgress to see if an in-doubt
transaction is still running, consult XidInMVCCSnapshot.  That requires
the same or fewer cycles as TransactionIdIsInProgress, and what's far
more important, it does not access shared data structures (at least in the
no-subxip-overflow case) so it incurs no contention.  Furthermore, we would
have had to check XidInMVCCSnapshot anyway before deciding that we were
allowed to see the tuple.

There should never be a case where XidInMVCCSnapshot says a transaction is
done while TransactionIdIsInProgress says it's still running.  The other
way around is quite possible though.  The result of that difference is that
HeapTupleSatisfiesMVCC will no longer set hint bits on tuples whose source
transactions recently finished but are still running according to our
snapshot.  The main cost of delaying the hint-bit setting is that repeated
visits to a just-committed tuple, by transactions none of which have
snapshots new enough to see the source transaction as done, will each
execute TransactionIdIsCurrentTransactionId, which they need not have done
before.  However, that's normally just a small overhead, and no contention
costs are involved; so it seems well worth the benefit of removing
TransactionIdIsInProgress calls during the life of the source transaction.

The core idea for this patch is due to Jeff Janes, who also did the legwork
proving its performance benefits.  His original proposal was to swap the
order of TransactionIdIsInProgress and XidInMVCCSnapshot calls in some
cases within HeapTupleSatisfiesMVCC.  That was a bit messy though.
The idea that we could dispense with calling TransactionIdIsInProgress
altogether was mine, as is the final patch.

9 years agorelease notes: abbreviated key speedup only for varchar/text
Bruce Momjian [Wed, 26 Aug 2015 18:46:48 +0000 (14:46 -0400)]
release notes:  abbreviated key speedup only for varchar/text

Report by Peter Geoghegan

Backpatch through 9.5

9 years ago9.5 release notes: mention lack of char() sort improvements
Bruce Momjian [Wed, 26 Aug 2015 14:33:02 +0000 (10:33 -0400)]
9.5 release notes:  mention lack of char() sort improvements

Report by Peter Geoghegan

Backpatch through 9.5

9 years agoReestablish alignment of pg_controldata output.
Joe Conway [Wed, 26 Aug 2015 01:45:44 +0000 (18:45 -0700)]
Reestablish alignment of pg_controldata output.

Until 9.4, pg_controldata output was all aligned. At some point
during 9.5 development, a new item was added, namely
"Current track_commit_timestamp setting:" which is two characters
too long to be aligned with the rest of the output. Fix this by
removing the noise word "Current" and adding the requisite number
of padding spaces. Since the six preceding items are also similar
in nature, remove "Current" and pad those as well in order to
maintain overall consistency. Backpatch to 9.5 where new offending
item was added.

9 years agoDocs: be explicit about datatype matching for lead/lag functions.
Tom Lane [Tue, 25 Aug 2015 23:11:17 +0000 (19:11 -0400)]
Docs: be explicit about datatype matching for lead/lag functions.

The default argument, if given, has to be of exactly the same datatype
as the first argument; but this was not stated in so many words, and
the error message you get about it might not lead your thought in the
right direction.  Per bug #13587 from Robert McGehee.

A quick scan says that these are the only two built-in functions with two
anyelement arguments and no other polymorphic arguments.  There are plenty
of cases of, eg, anyarray and anyelement, but those seem less likely to
confuse.  For instance this doesn't seem terribly hard to figure out:
"function array_remove(integer[], numeric) does not exist".  So I've
contented myself with fixing these two cases.

9 years agoFurther tweak wording of error messages about bad CONTINUE/EXIT statements.
Tom Lane [Tue, 25 Aug 2015 18:06:13 +0000 (14:06 -0400)]
Further tweak wording of error messages about bad CONTINUE/EXIT statements.

Per discussion, a little more verbosity seems called for.

9 years agoLimit the verbosity of memory context statistics dumps.
Tom Lane [Tue, 25 Aug 2015 17:09:48 +0000 (13:09 -0400)]
Limit the verbosity of memory context statistics dumps.

We had a report from Stefan Kaltenbrunner of a case in which postmaster
log files overran available disk space because multiple backends spewed
enormous context stats dumps upon hitting an out-of-memory condition.
Given the lack of similar reports, this isn't a common problem, but it
still seems worth doing something about.  However, we don't want to just
blindly truncate the output, because that might prevent diagnosis of OOM
problems.  What seems like a workable compromise is to limit the dump to
100 child contexts per parent, and summarize the space used within any
additional child contexts.  That should help because practical cases where
the dump gets long will typically be huge numbers of siblings under the
same parent context; while the additional debugging value from seeing
details about individual siblings beyond 100 will not be large, we hope.
Anyway it doesn't take much code or memory space to do this, so let's try
it like this and see how things go.

Since the summarization mechanism requires passing totals back up anyway,
I took the opportunity to add a "grand total" line to the end of the
printout.

9 years agoFix potential platform dependence in gist regression test.
Tom Lane [Tue, 25 Aug 2015 15:43:37 +0000 (11:43 -0400)]
Fix potential platform dependence in gist regression test.

The results of the KNN-search test cases were indeterminate, as they asked
the system to sort pairs of points that are exactly equidistant from the
query reference point.  It's a bit surprising that we've seen no
platform-specific failures from this in the buildfarm.  Perhaps IEEE-float
math is well enough standardized that no such failures will ever occur on
supported platforms ... but since this entire regression test has yet to be
shipped in any non-alpha release, that seems like an unduly optimistic
assumption.  Tweak the queries so that the correct output is uniquely
defined.

(The other queries in this test are also underdetermined; but it looks like
they are regurgitating index rows in insertion order, so for the moment
assume that that behavior is stable enough.)

Per Greg Stark's experiments with VAX.  Back-patch to 9.5 where this test
script was introduced.

9 years agoTweak wording of syntax error messages about bad CONTINUE/EXIT statements.
Tom Lane [Sun, 23 Aug 2015 21:34:47 +0000 (17:34 -0400)]
Tweak wording of syntax error messages about bad CONTINUE/EXIT statements.

Try to avoid any possible confusion about what these messages mean.

9 years agoReduce number of bytes examined by convert_one_string_to_scalar().
Tom Lane [Sun, 23 Aug 2015 19:15:47 +0000 (15:15 -0400)]
Reduce number of bytes examined by convert_one_string_to_scalar().

Previously, convert_one_string_to_scalar() would examine up to 20 bytes of
the input string, producing a scalar conversion with theoretical precision
far greater than is of any possible use considering the other limitations
on the accuracy of the resulting selectivity estimate.  (I think this
choice might pre-date the caller-level logic that strips any common prefix
of the strings; before that, there could have been value in scanning the
strings far enough to use all the precision available in a double.)

Aside from wasting cycles to little purpose, this choice meant that the
"denom" variable could grow to as much as 256^21 = 3.74e50, which could
overflow in some non-IEEE float arithmetics.  While we don't really support
any machines with non-IEEE arithmetic anymore, this still seems like quite
an unnecessary platform dependency.  Limit the scan to 12 bytes instead,
thus limiting "denom" to 256^13 = 2.03e31, a value more likely to be
computable everywhere.

Per testing by Greg Stark, which showed overflow failures in our standard
regression tests on VAX.

9 years agoAvoid use of float arithmetic in bipartite_match.c.
Tom Lane [Sun, 23 Aug 2015 17:02:13 +0000 (13:02 -0400)]
Avoid use of float arithmetic in bipartite_match.c.

Since the distances used in this algorithm are small integers (not more
than the size of the U set, in fact), there is no good reason to use float
arithmetic for them.  Use short ints instead: they're smaller, faster, and
require no special portability assumptions.

Per testing by Greg Stark, which disclosed that the code got into an
infinite loop on VAX for lack of IEEE-style float infinities.  We don't
really care all that much whether Postgres can run on a VAX anymore,
but there seems sufficient reason to change this code anyway.

In passing, make a few other small adjustments to make the code match
usual Postgres coding style a bit better.

9 years agoFix typo in C comment.
Kevin Grittner [Sun, 23 Aug 2015 15:38:57 +0000 (10:38 -0500)]
Fix typo in C comment.

Merlin Moncure
Backpatch to 9.5, where the misspelling was introduced