]> granicus.if.org Git - postgresql/log
postgresql
8 years agopostgres_fdw: Remove unnecessary variable.
Robert Haas [Wed, 10 Feb 2016 13:17:43 +0000 (08:17 -0500)]
postgres_fdw: Remove unnecessary variable.

It causes warnings in non-Assert-enabled builds.

Per report from Jeff Janes.

8 years agoAdd still more chattiness in server shutdown.
Tom Lane [Wed, 10 Feb 2016 00:36:21 +0000 (19:36 -0500)]
Add still more chattiness in server shutdown.

Further investigation says that there may be some slow operations after
we've finished ShutdownXLOG(), so add some more log messages to try to
isolate that.  This is all temporary code too.

8 years agopostgres_fdw: Remove unstable regression test.
Robert Haas [Tue, 9 Feb 2016 20:42:20 +0000 (15:42 -0500)]
postgres_fdw: Remove unstable regression test.

Per Tom Lane and the buildfarm.

8 years agopostgres_fdw: Push down joins to remote servers.
Robert Haas [Tue, 9 Feb 2016 19:00:50 +0000 (14:00 -0500)]
postgres_fdw: Push down joins to remote servers.

If we've got a relatively straightforward join between two tables,
this pushes that join down to the remote server instead of fetching
the rows for each table and performing the join locally.  Some cases
are not handled yet, such as SEMI and ANTI joins.  Also, we don't
yet attempt to create presorted join paths or parameterized join
paths even though these options do get tried for a base relation
scan.  Nevertheless, this seems likely to be a very significant win
in many practical cases.

Shigeru Hanada and Ashutosh Bapat, reviewed by Robert Haas, with
additional review at various points by Tom Lane, Etsuro Fujita,
KaiGai Kohei, and Jeevan Chalke.

8 years agoAdd more chattiness in server shutdown.
Tom Lane [Tue, 9 Feb 2016 16:21:46 +0000 (11:21 -0500)]
Add more chattiness in server shutdown.

Early returns from the buildfarm show that there's a bit of a gap in the
logging I added in 3971f64843b02e4a: the portion of CreateCheckPoint()
after CheckPointGuts() can take a fair amount of time.  Add a few more
log messages in that section of code.  This too shall be reverted later.

8 years agoTemporarily make pg_ctl and server shutdown a whole lot chattier.
Tom Lane [Mon, 8 Feb 2016 23:43:11 +0000 (18:43 -0500)]
Temporarily make pg_ctl and server shutdown a whole lot chattier.

This is a quick hack, due to be reverted when its purpose has been served,
to try to gather information about why some of the buildfarm critters
regularly fail with "postmaster does not shut down" complaints.  Maybe they
are just really overloaded, but maybe something else is going on.  Hence,
instrument pg_ctl to print the current time when it starts waiting for
postmaster shutdown and when it gives up, and add a lot of logging of the
current time in the server's checkpoint and shutdown code paths.

No attempt has been made to make this pretty.  I'm not even totally sure
if it will build on Windows, but we'll soon find out.

8 years agoRe-pgindent varlena.c.
Tom Lane [Mon, 8 Feb 2016 20:17:40 +0000 (15:17 -0500)]
Re-pgindent varlena.c.

Just to make sure previous commit worked ...

8 years agoRename typedef "string" to "VarString".
Tom Lane [Mon, 8 Feb 2016 20:15:56 +0000 (15:15 -0500)]
Rename typedef "string" to "VarString".

Since pgindent treats typedef names as global, the original coding of
b47b4dbf683f13e6 would have had rather nasty effects on the formatting
of other files in which "string" is used as a variable or field name.
Use a less generic name for this typedef, and rename some other
identifiers to match.

Peter Geoghegan, per gripe from me

8 years agoUse %u not %d to print OIDs.
Tom Lane [Mon, 8 Feb 2016 16:06:23 +0000 (11:06 -0500)]
Use %u not %d to print OIDs.

Oversight in commit 96198d94c.

Etsuro Fujita

8 years agoLast-minute updates for release notes.
Tom Lane [Mon, 8 Feb 2016 15:49:37 +0000 (10:49 -0500)]
Last-minute updates for release notes.

Security: CVE-2016-0773

8 years agoFix some regex issues with out-of-range characters and large char ranges.
Tom Lane [Mon, 8 Feb 2016 15:25:40 +0000 (10:25 -0500)]
Fix some regex issues with out-of-range characters and large char ranges.

Previously, our regex code defined CHR_MAX as 0xfffffffe, which is a
bad choice because it is outside the range of type "celt" (int32).
Characters approaching that limit could lead to infinite loops in logic
such as "for (c = a; c <= b; c++)" where c is of type celt but the
range bounds are chr.  Such loops will work safely only if CHR_MAX+1
is representable in celt, since c must advance to beyond b before the
loop will exit.

Fortunately, there seems no reason not to restrict CHR_MAX to 0x7ffffffe.
It's highly unlikely that Unicode will ever assign codes that high, and
none of our other backend encodings need characters beyond that either.

In addition to modifying the macro, we have to explicitly enforce character
range restrictions on the values of \u, \U, and \x escape sequences, else
the limit is trivially bypassed.

Also, the code for expanding case-independent character ranges in bracket
expressions had a potential integer overflow in its calculation of the
number of characters it could generate, which could lead to allocating too
small a character vector and then overwriting memory.  An attacker with the
ability to supply arbitrary regex patterns could easily cause transient DOS
via server crashes, and the possibility for privilege escalation has not
been ruled out.

Quite aside from the integer-overflow problem, the range expansion code was
unnecessarily inefficient in that it always produced a result consisting of
individual characters, abandoning the knowledge that we had a range to
start with.  If the input range is large, this requires excessive memory.
Change it so that the original range is reported as-is, and then we add on
any case-equivalent characters that are outside that range.  With this
approach, we can bound the number of individual characters allowed without
sacrificing much.  This patch allows at most 100000 individual characters,
which I believe to be more than the number of case pairs existing in
Unicode, so that the restriction will never be hit in practice.

It's still possible for range() to take awhile given a large character code
range, so also add statement-cancel detection to its loop.  The downstream
function dovec() also lacked cancel detection, and could take a long time
given a large output from range().

Per fuzz testing by Greg Stark.  Back-patch to all supported branches.

Security: CVE-2016-0773

8 years agoMake GIN regression test stable.
Fujii Masao [Mon, 8 Feb 2016 14:41:46 +0000 (23:41 +0900)]
Make GIN regression test stable.

Commit 7f46eaf added the regression test which checks that
gin_clean_pending_list() cleans up the GIN pending list and returns >0.
This usually works fine. But if autovacuum comes along and cleans
the list before gin_clean_pending_list() starts, the function may
return 0, and then the regression test may fail.

To fix the problem, this commit disables autovacuum on the target
index of gin_clean_pending_list() by setting autovacuum_enabled
reloption to off when creating the table.

Also this commit sets gin_pending_list_limit reloption to 4MB on
the target index. Otherwise when running "make installcheck" with
small gin_pending_list_limit GUC, insertions of data may trigger
the cleanup of pending list before gin_clean_pending_list() starts
and the function may return 0. This could cause the regression test
to fail.

Per buildfarm member spoonbill.

Reported-By: Tom Lane
8 years agoFix overeager pushdown of HAVING clauses when grouping sets are used.
Andres Freund [Mon, 8 Feb 2016 10:03:31 +0000 (11:03 +0100)]
Fix overeager pushdown of HAVING clauses when grouping sets are used.

In 61444bfb we started to allow HAVING clauses to be fully pushed down
into WHERE, even when grouping sets are in use. That turns out not to
work correctly, because grouping sets can "produce" NULLs, meaning that
filtering in WHERE and HAVING can have different results, even when no
aggregates or volatile functions are involved.

Instead only allow pushdown of empty grouping sets.

It'd be nice to do better, but the exact mechanics of deciding which
cases are safe are still being debated. It's important to give correct
results till we find a good solution, and such a solution might not be
appropriate for backpatching anyway.

Bug: #13863
Reported-By: 'wrb'
Diagnosed-By: Dean Rasheed
Author: Andrew Gierth
Reviewed-By: Dean Rasheed and Andres Freund
Discussion: 20160113183558.12989.56904@wrigleys.postgresql.org
Backpatch: 9.5, where grouping sets were introduced

8 years agoImprove documentation about PRIMARY KEY constraints.
Tom Lane [Sun, 7 Feb 2016 21:02:44 +0000 (16:02 -0500)]
Improve documentation about PRIMARY KEY constraints.

Get rid of the false implication that PRIMARY KEY is exactly equivalent to
UNIQUE + NOT NULL.  That was more-or-less true at one time in our
implementation, but the standard doesn't say that, and we've grown various
features (many of them required by spec) that treat a pkey differently from
less-formal constraints.  Per recent discussion on pgsql-general.

I failed to resist the temptation to do some other wordsmithing in the
same area.

8 years agoFix deparsing of ON CONFLICT arbiter WHERE clauses.
Tom Lane [Sun, 7 Feb 2016 19:57:24 +0000 (14:57 -0500)]
Fix deparsing of ON CONFLICT arbiter WHERE clauses.

The parser doesn't allow qualification of column names appearing in
these clauses, but ruleutils.c would sometimes qualify them, leading
to dump/reload failures.  Per bug #13891 from Onder Kalaci.

(In passing, make stanzas in ruleutils.c that save/restore varprefix
more consistent.)

Peter Geoghegan

8 years agoRelease notes for 9.5.1, 9.4.6, 9.3.11, 9.2.15, 9.1.20.
Tom Lane [Sun, 7 Feb 2016 19:16:31 +0000 (14:16 -0500)]
Release notes for 9.5.1, 9.4.6, 9.3.11, 9.2.15, 9.1.20.

8 years agoExecHashRemoveNextSkewBucket must physically copy tuples to main hashtable.
Tom Lane [Sun, 7 Feb 2016 17:29:17 +0000 (12:29 -0500)]
ExecHashRemoveNextSkewBucket must physically copy tuples to main hashtable.

Commit 45f6240a8fa9d355 added an assumption in ExecHashIncreaseNumBatches
and ExecHashIncreaseNumBuckets that they could find all tuples in the main
hash table by iterating over the "dense storage" introduced by that patch.
However, ExecHashRemoveNextSkewBucket continued its old practice of simply
re-linking deleted skew tuples into the main table's hashchains.  Hence,
such tuples got lost during any subsequent increase in nbatch or nbuckets,
and would never get joined, as reported in bug #13908 from Seth P.

I (tgl) think that the aforesaid commit has got multiple design issues
and should be reworked rather completely; but there is no time for that
right now, so band-aid the problem by making ExecHashRemoveNextSkewBucket
physically copy deleted skew tuples into the "dense storage" arena.

The added test case is able to exhibit the problem by means of fooling the
planner with a WHERE condition that it will underestimate the selectivity
of, causing the initial nbatch estimate to be too small.

Tomas Vondra and Tom Lane.  Thanks to David Johnston for initial
investigation into the bug report.

8 years agoFix parallel-safety markings for pg_upgrade functions.
Robert Haas [Sun, 7 Feb 2016 16:45:21 +0000 (11:45 -0500)]
Fix parallel-safety markings for pg_upgrade functions.

These establish backend-local state which will not be copied to
parallel workers, so they must be marked parallel-restricted, not
parallel-safe.

8 years agoIntroduce a new GUC force_parallel_mode for testing purposes.
Robert Haas [Sun, 7 Feb 2016 16:39:22 +0000 (11:39 -0500)]
Introduce a new GUC force_parallel_mode for testing purposes.

When force_parallel_mode = true, we enable the parallel mode restrictions
for all queries for which this is believed to be safe.  For the subset of
those queries believed to be safe to run entirely within a worker, we spin
up a worker and run the query there instead of running it in the
original process.  When force_parallel_mode = regress, make additional
changes to allow the regression tests to run cleanly even though parallel
workers have been injected under the hood.

Taken together, this facilitates both better user testing and better
regression testing of the parallelism code.

Robert Haas, with help from Amit Kapila and Rushabh Lathia.

8 years agoIntroduce group locking to prevent parallel processes from deadlocking.
Robert Haas [Sun, 7 Feb 2016 15:16:13 +0000 (10:16 -0500)]
Introduce group locking to prevent parallel processes from deadlocking.

For locking purposes, we now regard heavyweight locks as mutually
non-conflicting between cooperating parallel processes.  There are some
possible pitfalls to this approach that are not to be taken lightly,
but it works OK for now and can be changed later if we find a better
approach.  Without this, it's very easy for parallel queries to
silently self-deadlock if the user backend holds strong relation locks.

Robert Haas, with help from Amit Kapila.  Thanks to Noah Misch and
Andres Freund for extensive discussion of possible issues with this
approach.

8 years agoImprove speed of timestamp/time/date output functions.
Tom Lane [Sun, 7 Feb 2016 04:11:28 +0000 (23:11 -0500)]
Improve speed of timestamp/time/date output functions.

It seems that sprintf(), at least in glibc's version, is unreasonably slow
compared to hand-rolled code for printing integers.  Replacing most uses of
sprintf() in the datetime.c output functions with special-purpose code
turns out to give more than a 2X speedup in COPY of a table with a single
timestamp column; which is pretty impressive considering all the other
logic in that code path.

David Rowley and Andres Freund, reviewed by Peter Geoghegan and myself

8 years agoFix comment block trashed by pgindent.
Tom Lane [Sat, 6 Feb 2016 20:13:36 +0000 (15:13 -0500)]
Fix comment block trashed by pgindent.

Looks like I put the protective dashes in the wrong place in f4e4b32743.

8 years agoImprove HJDEBUG code a bit.
Tom Lane [Sat, 6 Feb 2016 20:05:23 +0000 (15:05 -0500)]
Improve HJDEBUG code a bit.

Commit 30d7ae3c76d2de144232ae6ab328ca86b70e72c3 introduced an HJDEBUG
stanza that probably didn't compile at the time, and definitely doesn't
compile now, because it refers to a nonexistent variable.  It doesn't seem
terribly useful anyway, so just get rid of it.

While I'm fooling with it, use %z modifier instead of the obsolete hack of
casting size_t to unsigned long, and include the HashJoinTable's address in
each printout so that it's possible to distinguish the activities of
multiple hashjoins occurring in one query.

Noted while trying to use HJDEBUG to investigate bug #13908.  Back-patch
to 9.5, because code that doesn't compile is certainly not very helpful.

8 years agoAdd missing "static" qualifier.
Tom Lane [Sat, 6 Feb 2016 17:21:14 +0000 (12:21 -0500)]
Add missing "static" qualifier.

Per buildfarm member pademelon.

8 years agoComment on dead code in AtAbort_Portals() and AtSubAbort_Portals().
Noah Misch [Sat, 6 Feb 2016 01:23:40 +0000 (20:23 -0500)]
Comment on dead code in AtAbort_Portals() and AtSubAbort_Portals().

Reviewed by Tom Lane and Robert Haas.

8 years agoForce certain "pljava" custom GUCs to be PGC_SUSET.
Noah Misch [Sat, 6 Feb 2016 01:22:51 +0000 (20:22 -0500)]
Force certain "pljava" custom GUCs to be PGC_SUSET.

Future PL/Java versions will close CVE-2016-0766 by making these GUCs
PGC_SUSET.  This PostgreSQL change independently mitigates that PL/Java
vulnerability, helping sites that update PostgreSQL more frequently than
PL/Java.  Back-patch to 9.1 (all supported versions).

8 years agoFirst-draft release notes for 9.4.6.
Tom Lane [Fri, 5 Feb 2016 22:06:23 +0000 (17:06 -0500)]
First-draft release notes for 9.4.6.

As usual, the release notes for other branches will be made by cutting
these down, but put them up for community review first.

8 years agoUpdate time zone data files to tzdata release 2016a.
Tom Lane [Fri, 5 Feb 2016 15:59:09 +0000 (10:59 -0500)]
Update time zone data files to tzdata release 2016a.

DST law changes in Cayman Islands, Metlakatla, Trans-Baikal Territory
(Zabaykalsky Krai).  Historical corrections for Pakistan.

8 years agoFix typo in comment.
Robert Haas [Fri, 5 Feb 2016 13:11:00 +0000 (08:11 -0500)]
Fix typo in comment.

Michael Paquier

8 years agoRemove parallel-safety check from GetExistingLocalJoinPath.
Robert Haas [Fri, 5 Feb 2016 13:07:38 +0000 (08:07 -0500)]
Remove parallel-safety check from GetExistingLocalJoinPath.

Commit a104a017fc5f67ff5d9c374cd831ac3948a874c2 has this check because
I added it to the submitted patch before commit, but that was entirely
wrongheaded, as explained to me by Ashutosh Bapat, who also wrote this
patch.

8 years agoFix small goof in comment.
Robert Haas [Fri, 5 Feb 2016 13:04:48 +0000 (08:04 -0500)]
Fix small goof in comment.

Peter Geoghegan

8 years agoFix typo.
Robert Haas [Fri, 5 Feb 2016 12:56:59 +0000 (07:56 -0500)]
Fix typo.

Amit Kapila

8 years agoAdd num_nulls() and num_nonnulls() to count NULL arguments.
Tom Lane [Fri, 5 Feb 2016 04:03:10 +0000 (23:03 -0500)]
Add num_nulls() and num_nonnulls() to count NULL arguments.

An example use-case is "CHECK(num_nonnulls(a,b,c) = 1)" to assert that
exactly one of a,b,c isn't NULL.  The functions are variadic, so they
can also be pressed into service to count the number of null or nonnull
elements in an array.

Marko Tiikkaja, reviewed by Pavel Stehule

8 years agopostgres_fdw: pgindent run.
Robert Haas [Fri, 5 Feb 2016 03:30:08 +0000 (22:30 -0500)]
postgres_fdw: pgindent run.

In preparation for upcoming commits.

8 years agopostgres_fdw: Avoid possible misbehavior when RETURNING tableoid column only.
Robert Haas [Fri, 5 Feb 2016 03:15:50 +0000 (22:15 -0500)]
postgres_fdw: Avoid possible misbehavior when RETURNING tableoid column only.

deparseReturningList ended up adding up RETURNING NULL to the code, but
code elsewhere saw an empty list of attributes and concluded that it
should not expect tuples from the remote side.

Etsuro Fujita and Robert Haas, reviewed by Thom Brown

8 years agoWhen modifying a foreign table, initialize tableoid field properly.
Robert Haas [Fri, 5 Feb 2016 02:15:57 +0000 (21:15 -0500)]
When modifying a foreign table, initialize tableoid field properly.

Failure to do this can cause AFTER ROW triggers or RETURNING expressions
that reference this field to misbehave.

Etsuro Fujita, reviewed by Thom Brown

8 years agoImprove error message
Peter Eisentraut [Fri, 5 Feb 2016 01:41:32 +0000 (20:41 -0500)]
Improve error message

8 years agoAdd some additional core functions to support join pushdown for FDWs.
Robert Haas [Thu, 4 Feb 2016 22:05:09 +0000 (17:05 -0500)]
Add some additional core functions to support join pushdown for FDWs.

GetExistingLocalJoinPath() is useful for handling EvalPlanQual rechecks
properly, and GetUserMappingById() is needed to make sure you're using
the right credentials.

Shigeru Hanada, Etsuro Fujita, Ashutosh Bapat, Robert Haas

8 years agoChange the way that LWLocks for extensions are allocated.
Robert Haas [Thu, 4 Feb 2016 21:43:04 +0000 (16:43 -0500)]
Change the way that LWLocks for extensions are allocated.

The previous RequestAddinLWLocks() method had several disadvantages.
First, the locks would be in the main tranche; we've recently decided
that it's useful for LWLocks used for separate purposes to have
separate tranche IDs.  Second, there wasn't any correlation between
what code called RequestAddinLWLocks() and what code called
LWLockAssign(); when multiple modules are in use, it could become
quite difficult to troubleshoot problems where LWLockAssign() ran out
of locks.  To fix, create a concept of named LWLock tranches which
can be used either by extension or by core code.

Amit Kapila and Robert Haas

8 years agoSimplify syntax diagram for REINDEX.
Tom Lane [Thu, 4 Feb 2016 18:58:40 +0000 (13:58 -0500)]
Simplify syntax diagram for REINDEX.

Since there currently is only one possible parenthesized option, namely
VERBOSE, it's a bit pointless to show it with "{ } [, ... ]".  The curly
braces are useless and therefore confusing, as seen in a recent question
from Karsten Hilbert.  Remove the extra decoration for the time being;
we can put it back when and if REINDEX grows some more options.

8 years agoIn pg_dump, ensure that view triggers are processed after view rules.
Tom Lane [Thu, 4 Feb 2016 05:26:10 +0000 (00:26 -0500)]
In pg_dump, ensure that view triggers are processed after view rules.

If a view is split into CREATE TABLE + CREATE RULE to break a circular
dependency, then any triggers on the view must be dumped/reloaded after
the CREATE RULE; else the backend may reject the CREATE TRIGGER because
it's the wrong type of trigger for a plain table.  This works all right
in plain dump/restore because of pg_dump's sorting heuristic that places
triggers after rules.  However, when using parallel restore, the ordering
must be enforced by a dependency --- and we didn't have one.

Fixing this is a mere matter of adding an addObjectDependency() call,
except that we need to be able to find all the triggers belonging to the
view relation, and there was no easy way to do that.  Add fields to
pg_dump's TableInfo struct to remember where the associated TriggerInfo
struct(s) are.

Per bug report from Dennis Kögel.  The failure can be exhibited at least
as far back as 9.1, so back-patch to all supported branches.

8 years agoExtend sortsupport for text to more opclasses.
Robert Haas [Wed, 3 Feb 2016 19:17:35 +0000 (14:17 -0500)]
Extend sortsupport for text to more opclasses.

Have varlena.c expose an interface that allows the char(n), bytea, and
bpchar types to piggyback on a now-generalized SortSupport for text.
This pushes a little more knowledge of the bpchar/char(n) type into
varlena.c than might be preferred, but that seems like the approach
that creates least friction.  Also speed things up for index builds
that use text_pattern_ops or varchar_pattern_ops.

This patch does quite a bit of renaming, but it seems likely to be
worth it, so as to avoid future confusion about the fact that this code
is now more generally used than the old names might have suggested.

Peter Geoghegan, reviewed by Álvaro Herrera and Andreas Karlsson,
with small tweaks by me.

8 years agoAdd hstore_to_jsonb() and hstore_to_jsonb_loose() to hstore documentation.
Tom Lane [Wed, 3 Feb 2016 17:56:40 +0000 (12:56 -0500)]
Add hstore_to_jsonb() and hstore_to_jsonb_loose() to hstore documentation.

These were never documented anywhere user-visible.  Tut tut.

8 years agoAllow parallel custom and foreign scans.
Robert Haas [Wed, 3 Feb 2016 17:46:18 +0000 (12:46 -0500)]
Allow parallel custom and foreign scans.

This patch doesn't put the new infrastructure to use anywhere, and
indeed it's not clear how it could ever be used for something like
postgres_fdw which has to send an SQL query and wait for a reply,
but there might be FDWs or custom scan providers that are CPU-bound,
so let's give them a way to join club parallel.

KaiGai Kohei, reviewed by me.

8 years agodoc: Fix stand-alone INSTALL file build
Peter Eisentraut [Wed, 3 Feb 2016 17:31:33 +0000 (12:31 -0500)]
doc: Fix stand-alone INSTALL file build

Commit 7d17e683fcc28a1b371c7dd02935728cd2cbf9bf introduced an external
link.

8 years agoMake hstore_to_jsonb_loose match hstore_to_json_loose on what's a number.
Tom Lane [Wed, 3 Feb 2016 17:03:50 +0000 (12:03 -0500)]
Make hstore_to_jsonb_loose match hstore_to_json_loose on what's a number.

Commit e09996ff8dee3f70 removed some ad-hoc code in hstore_to_json_loose
that determined whether an hstore value string looked like a number,
in favor of calling the JSON parser's is-it-a-number code.  However,
it neglected the fact that the exact same code appeared in
hstore_to_jsonb_loose.

This is not a bug, exactly, because the requirements on the two functions
are not the same: hstore_to_json_loose must accept only syntactically legal
JSON numbers as numbers, or it will produce invalid JSON output, as per bug
#12070 which spawned the prior commit.  But hstore_to_jsonb_loose could
accept anything that numeric_in will eat, other than Inf and NaN.

Nonetheless it seems surprising and arbitrary that the two functions don't
use the same rules for what is a number versus what is a string; especially
since they did use the same rules before the aforesaid commit.  For one
thing, that means that doing hstore_to_json_loose and then casting to jsonb
can produce results different from doing just hstore_to_jsonb_loose.

Hence, change hstore_to_jsonb_loose's logic to match hstore_to_json_loose,
ie, hstore values are treated as numbers when they match the JSON syntax
for numbers.

No back-patch, since this is more in the nature of a definitional change
than a bug fix.

8 years agoCode review for commit dc203dc3ac40a4b02b92fb827848a547d2957153.
Robert Haas [Wed, 3 Feb 2016 16:53:46 +0000 (11:53 -0500)]
Code review for commit dc203dc3ac40a4b02b92fb827848a547d2957153.

Remove duplicate assignment.  This part by Ashutosh Bapat.

Remove now-obsolete comment.  This part by me, although the pending
join pushdown patch does something similar, and for the same reason:
there's no reason to keep two lists of the things in the fdw_private
structure that have to be kept in sync with each other.

8 years agoRemove CustomPath's TextOutCustomPath method.
Robert Haas [Wed, 3 Feb 2016 15:38:50 +0000 (10:38 -0500)]
Remove CustomPath's TextOutCustomPath method.

You can't really do anything useful with this in the form it currently
exists; among other problems, there's no way to reread whatever
information might be produced when the path is output.  Work is
underway to replace this with a more useful and more general system of
extensible nodes, but let's start by getting rid of this bit.

Extracted from a larger patch by KaiGai Kohei.

8 years agopostgres_fdw: Allow fetch_size to be set per-table or per-server.
Robert Haas [Wed, 3 Feb 2016 14:01:59 +0000 (09:01 -0500)]
postgres_fdw: Allow fetch_size to be set per-table or per-server.

The default fetch size of 100 rows might not be right in every
environment, so allow users to configure it.

Corey Huinker, reviewed by Kyotaro Horiguchi, Andres Freund, and me.

8 years agoFix IsValidJsonNumber() to notice trailing non-alphanumeric garbage.
Tom Lane [Wed, 3 Feb 2016 06:39:08 +0000 (01:39 -0500)]
Fix IsValidJsonNumber() to notice trailing non-alphanumeric garbage.

Commit e09996ff8dee3f70 was one brick shy of a load: it didn't insist
that the detected JSON number be the whole of the supplied string.
This allowed inputs such as "2016-01-01" to be misdetected as valid JSON
numbers.  Per bug #13906 from Dmitry Ryabov.

In passing, be more wary of zero-length input (I'm not sure this can
happen given current callers, but better safe than sorry), and do some
minor cosmetic cleanup.

8 years agoAdd support for systemd service notifications
Peter Eisentraut [Tue, 17 Nov 2015 11:46:17 +0000 (06:46 -0500)]
Add support for systemd service notifications

Insert sd_notify() calls at server start and stop for integration with
systemd.  This allows the use of systemd service units of type "notify",
which greatly simplifies the systemd configuration.

Reviewed-by: Pavel Stěhule <pavel.stehule@gmail.com>
8 years agoImprove error reporting when location specified by postgres -D does not exist
Peter Eisentraut [Tue, 17 Nov 2015 11:47:18 +0000 (06:47 -0500)]
Improve error reporting when location specified by postgres -D does not exist

Previously, the first error seen would be that postgresql.conf does not
exist.  But for the case where the whole directory does not exist, give
an error message about that, together with a hint for how to create one.

8 years agoRemove printQueryOpt.quote field.
Tom Lane [Tue, 2 Feb 2016 20:26:21 +0000 (15:26 -0500)]
Remove printQueryOpt.quote field.

This field was included in the original definition of the printQueryOpt
struct in commit a45195a191eec367, but it was not used anywhere in that
commit, nor since then.  Spotted by Dickson S. Guedes.

8 years agoDon't test for system columns on join relations
Alvaro Herrera [Tue, 2 Feb 2016 18:20:02 +0000 (19:20 +0100)]
Don't test for system columns on join relations

create_foreignscan_plan needs to know whether any system columns are
requested from a relation (this flag is needed by ForeignNext during
execution).  However, for join relations this is a pointless test,
because it's not possible to request system columns from them, so
remove the check.

Author: Etsuro Fujita
Discussion: http://www.postgresql.org/message-id/56AA0FC5.9000207@lab.ntt.co.jp
Reviewed-by: David Rowley, Robert Haas
8 years agoRemove unnecessary "implementation of FOO operator" DESCR() entries.
Tom Lane [Tue, 2 Feb 2016 16:52:27 +0000 (11:52 -0500)]
Remove unnecessary "implementation of FOO operator" DESCR() entries.

Apparently at least one committer hasn't gotten the word that these do not
need to be maintained by hand, since initdb will create them automatically.
Noted while fixing bug #13905.

No catversion bump since the post-initdb state is exactly the same either
way.  I don't see a need for back-patch, either.

8 years agoFix pg_description entries for jsonb_to_record() and jsonb_to_recordset().
Tom Lane [Tue, 2 Feb 2016 16:39:50 +0000 (11:39 -0500)]
Fix pg_description entries for jsonb_to_record() and jsonb_to_recordset().

All the other jsonb function descriptions refer to the arguments as being
"jsonb", but these two said "json".  Make it consistent.  Per bug #13905
from Petru Florin Mihancea.

No catversion bump --- we can't force one in the back branches, and this
isn't very critical anyway.

8 years agoFix typo in comment
Magnus Hagander [Tue, 2 Feb 2016 12:49:02 +0000 (13:49 +0100)]
Fix typo in comment

8 years agoFix lossy KNN GiST when ordering operator returns non-float8 value.
Teodor Sigaev [Tue, 2 Feb 2016 12:20:33 +0000 (15:20 +0300)]
Fix lossy KNN GiST when ordering operator returns non-float8 value.

KNN GiST with recheck flag should return to executor the same type as ordering
operator, GiST detects this type by looking to return type of function which
implements ordering operator. But occasionally detecting code works after
replacing ordering operator function to distance support function.
Distance support function always returns float8, so, detecting code get float8
instead of actual return type of ordering operator.

Built-in opclasses don't have ordering operator which doesn't return
non-float8 value, so, tests are impossible here, at least now.

Backpatch to 9.5 where lozzy KNN was introduced.

Author: Alexander Korotkov
Report by: Artur Zakirov

8 years agoMake all built-in lwlock tranche IDs fixed.
Robert Haas [Tue, 2 Feb 2016 11:42:14 +0000 (06:42 -0500)]
Make all built-in lwlock tranche IDs fixed.

This makes the values more stable, which seems like a good thing for
anybody who needs to look at at them.

Alexander Korotkov and Amit Kapila

8 years agopgbench: allow per-script statistics
Alvaro Herrera [Mon, 1 Feb 2016 14:55:33 +0000 (15:55 +0100)]
pgbench: allow per-script statistics

Provide per-script statistical info (count of transactions executed
under that script, average latency for the whole script) after a
multi-script run, adding an intermediate level of detail to existing
global stats and per-command stats.

Author: Fabien Coelho
Reviewer: Michaël Paquier, Álvaro Herrera

8 years agopgbench: Install guards against obscure overflow conditions.
Robert Haas [Mon, 1 Feb 2016 13:23:41 +0000 (08:23 -0500)]
pgbench: Install guards against obscure overflow conditions.

Dividing INT_MIN by -1 or taking INT_MIN modulo -1 can sometimes
cause floating-point exceptions or otherwise misbehave.

Fabien Coelho and Michael Paquier

8 years agoVarious fixes to "ALTER ... SET/RESET" tab completions
Fujii Masao [Mon, 1 Feb 2016 13:19:51 +0000 (22:19 +0900)]
Various fixes to "ALTER ... SET/RESET" tab completions

Add
- ALTER SYSTEM SET/RESET ... -> GUC variables
- ALTER TABLE ... SET WITH -> OIDS
- ALTER DATABASE/FUNCTION/ROLE/USER ... SET/RESET -> GUC variables
- ALTER DATABASE/FUNCTION/ROLE/USER ... SET ... -> FROM CURRENT/TO
- ALTER DATABASE/FUNCTION/ROLE/USER ... SET ... TO/= -> possible values

Author: Fujii Masao
Reviewed-by: Michael Paquier, Masahiko Sawada
8 years agoMake sure ecpg header files do not have a comment lasting several lines, one of
Michael Meskes [Mon, 1 Feb 2016 12:10:40 +0000 (13:10 +0100)]
Make sure ecpg header files do not have a comment lasting several lines, one of
which is a preprocessor directive. This leads ecpg to incorrectly parse the comment as nested.

8 years agoFix typos in comments
Magnus Hagander [Mon, 1 Feb 2016 10:43:48 +0000 (11:43 +0100)]
Fix typos in comments

Author: Michael Paquier

8 years agoFix misspelled function name in comment.
Heikki Linnakangas [Mon, 1 Feb 2016 08:10:24 +0000 (10:10 +0200)]
Fix misspelled function name in comment.

8 years agoFix error in documentated use of mingw-w64 compilers
Andrew Dunstan [Sun, 31 Jan 2016 00:28:44 +0000 (19:28 -0500)]
Fix error in documentated use of mingw-w64 compilers

Error reported by Igal Sapir.

8 years agoFix whitespace
Peter Eisentraut [Sat, 30 Jan 2016 20:58:20 +0000 (15:58 -0500)]
Fix whitespace

8 years agopostgres_fdw: More preliminary refactoring for upcoming join pushdown.
Robert Haas [Sat, 30 Jan 2016 15:32:38 +0000 (10:32 -0500)]
postgres_fdw: More preliminary refactoring for upcoming join pushdown.

The code that generates a complete SQL query for a given foreign relation
was repeated in two places, and they didn't quite agree: the EXPLAIN case
left out the locking clause.  Centralize the code so we get the same
behavior everywhere, and adjust calling conventions and which functions
are static vs. extern accordingly .  Centralize the code so we get the same
behavior everywhere, and adjust calling conventions and which functions
are static vs. extern accordingly.

Ashutosh Bapat, reviewed and slightly adjusted by me.

8 years agoMigrate replication slot I/O locks into a separate tranche.
Robert Haas [Fri, 29 Jan 2016 14:44:29 +0000 (09:44 -0500)]
Migrate replication slot I/O locks into a separate tranche.

This is following in a long train of similar changes and for the same
reasons - see b319356f0e94a6482c726cf4af96597c211d8d6e and
fe702a7b3f9f2bc5bf6d173166d7d55226af82c8 inter alia.

Author: Amit Kapila
Reviewed-by: Alexander Korotkov, Robert Haas
8 years agoMigrate PGPROC's backendLock into PGPROC itself, using a new tranche.
Robert Haas [Fri, 29 Jan 2016 13:10:47 +0000 (08:10 -0500)]
Migrate PGPROC's backendLock into PGPROC itself, using a new tranche.

Previously, each PGPROC's backendLock was part of the main tranche,
and the PGPROC just contained a pointer.  Now, the actual LWLock is
part of the PGPROC.

As with previous, similar patches, this makes it significantly easier
to identify these lwlocks in LWLOCK_STATS or Trace_lwlocks output
and improves modularity.

Author: Ildus Kurbangaliev
Reviewed-by: Amit Kapila, Robert Haas
8 years agopgbench: refactor handling of stats tracking
Alvaro Herrera [Fri, 29 Jan 2016 12:05:08 +0000 (13:05 +0100)]
pgbench: refactor handling of stats tracking

This doesn't add any functionality but just shuffles things around so
that it can be reused and improved later.

Author: Fabien Coelho
Reviewed-by: Michael Paquier, Álvaro Herrera
8 years agoFix incorrect pattern-match processing in psql's \det command.
Tom Lane [Fri, 29 Jan 2016 09:28:02 +0000 (10:28 +0100)]
Fix incorrect pattern-match processing in psql's \det command.

listForeignTables' invocation of processSQLNamePattern did not match up
with the other ones that handle potentially-schema-qualified names; it
failed to make use of pg_table_is_visible() and also passed the name
arguments in the wrong order.  Bug seems to have been aboriginal in commit
0d692a0dc9f0e532.  It accidentally sort of worked as long as you didn't
inquire too closely into the behavior, although the silliness was later
exposed by inconsistencies in the test queries added by 59efda3e50ca4de6
(which I probably should have questioned at the time, but didn't).

Per bug #13899 from Reece Hart.  Patch by Reece Hart and Tom Lane.
Back-patch to all affected branches.

8 years agoFix syntax descriptions for replication commands in logicaldecoding.sgml
Fujii Masao [Fri, 29 Jan 2016 03:14:56 +0000 (12:14 +0900)]
Fix syntax descriptions for replication commands in logicaldecoding.sgml

Patch-by: Oleksandr Shulgin
Reviewed-by: Craig Ringer and Fujii Masao
Backpatch-through: 9.4 where logical decoding was introduced

8 years agopostgres_fdw: Refactor deparsing code for locking clauses.
Robert Haas [Thu, 28 Jan 2016 21:44:01 +0000 (16:44 -0500)]
postgres_fdw: Refactor deparsing code for locking clauses.

The upcoming patch to allow join pushdown in postgres_fdw needs to use
this code multiple times, which requires moving it to deparse.c.  That
seems like a good idea anyway, so do that now both on general principle
and to simplify the future patch.

Inspired by a patch by Shigeru Hanada and Ashutosh Bapat, but I did
it a little differently than what that patch did.

8 years agoOnly try to push down foreign joins if the user mapping OIDs match.
Robert Haas [Thu, 28 Jan 2016 19:05:36 +0000 (14:05 -0500)]
Only try to push down foreign joins if the user mapping OIDs match.

Previously, the foreign join pushdown infrastructure left the question
of security entirely up to individual FDWs, but it would be easy for
a foreign data wrapper to inadvertently open up subtle security holes
that way.  So, make it the core code's job to determine which user
mapping OID is relevant, and don't attempt join pushdown unless it's
the same for all relevant relations.

Per a suggestion from Tom Lane.  Shigeru Hanada and Ashutosh Bapat,
reviewed by Etsuro Fujita and KaiGai Kohei, with some further
changes by me.

8 years agoAdd missing quotation mark.
Robert Haas [Thu, 28 Jan 2016 17:21:51 +0000 (12:21 -0500)]
Add missing quotation mark.

This fix accidentally got left out of the previous commit.

8 years agoAvoid multiple foreign server connections when all use same user mapping.
Robert Haas [Thu, 28 Jan 2016 17:05:19 +0000 (12:05 -0500)]
Avoid multiple foreign server connections when all use same user mapping.

Previously, postgres_fdw's connection cache was keyed by user OID and
server OID, but this can lead to multiple connections when it's not
really necessary.  In particular, if all relevant users are mapped to
the public user mapping, then their connection options are certainly
the same, so one connection can be used for all of them.

While we're cleaning things up here, drop the "server" argument to
GetConnection(), which isn't really needed.  This saves a few cycles
because callers no longer have to look this up; the function itself
does, but only when establishing a new connection, not when reusing
an existing one.

Ashutosh Bapat, with a few small changes by me.

8 years agoAdd [NO]BYPASSRLS options to CREATE USER and ALTER USER docs.
Robert Haas [Thu, 28 Jan 2016 14:29:04 +0000 (09:29 -0500)]
Add [NO]BYPASSRLS options to CREATE USER and ALTER USER docs.

Patch-by: Filip Rembiałkowski
Reviewed-by: Robert Haas
Backpatch-through: 9.5

8 years agoFix spi_worker mention in bgworker documentation
Alvaro Herrera [Thu, 28 Jan 2016 13:08:21 +0000 (14:08 +0100)]
Fix spi_worker mention in bgworker documentation

The documentation mentioned contrib/ but the module was moved to
src/test/modules/ by commit 22dfd116a127a of 9.5 era.

Problem pointed out by Dickson Guedes in bug #13896
Backpatch-to: 9.5.
8 years agoFix typos in comments and doc
Fujii Masao [Thu, 28 Jan 2016 07:47:36 +0000 (16:47 +0900)]
Fix typos in comments and doc

overriden -> overridden

The misspelling in create_extension.sgml was introduced in b67aaf2,
so no need to backpatch.

8 years agoAdd gin_clean_pending_list function to clean up GIN pending list
Fujii Masao [Thu, 28 Jan 2016 03:57:52 +0000 (12:57 +0900)]
Add gin_clean_pending_list function to clean up GIN pending list

This function cleans up the pending list of the GIN index by
moving entries in it to the main GIN data structure in bulk.
It returns the number of pages cleaned up from the pending list.

This function is useful, for example, when the pending list
needs to be cleaned up *quickly* to improve the performance of
the search using GIN index. VACUUM can do the same thing, too,
but it may take days to run on a large table.

Jeff Janes,
reviewed by Julien Rouhaud, Jaime Casanova, Alvaro Herrera and me.

Discussion: CAMkU=1x8zFkpfnozXyt40zmR3Ub_kHu58LtRmwHUKRgQss7=iQ@mail.gmail.com

8 years agoAssert that create_unique_path returns non-NULL.
Robert Haas [Thu, 28 Jan 2016 03:03:18 +0000 (22:03 -0500)]
Assert that create_unique_path returns non-NULL.

Per off-list discussion with Tom Lane and Michael Paquier, Coverity
gets unhappy if this is not done.

8 years agoFix cross-version pg_dump for aggregate combine functions.
Robert Haas [Thu, 28 Jan 2016 02:45:07 +0000 (21:45 -0500)]
Fix cross-version pg_dump for aggregate combine functions.

Fixes a defect in commit a7de3dc5c346e07e0439275982569996e645b3c2.

David Rowley, per report from Jeff Janes, who also checked that the
fix works.

8 years agoFix volatility marking of pg_size_pretty function
Fujii Masao [Wed, 27 Jan 2016 02:13:31 +0000 (11:13 +0900)]
Fix volatility marking of pg_size_pretty function

pg_size_pretty function should be marked immutable rather than volatile
because it always returns the same result given the same argument.

Pavel Stehule

8 years agopgbench: improve multi-script support
Alvaro Herrera [Wed, 27 Jan 2016 01:54:22 +0000 (02:54 +0100)]
pgbench: improve multi-script support

Previously, it was possible to specify one or several custom scripts to
run, or only one of the builtin scripts.  With this patch it is also
possible to specify to run the builtin scripts multiple times, using the
new -b option.  Also, unify the code for both cases; this eases future
pgbench improvements.

Author: Fabien Coelho
Review: Michaël Paquier, Álvaro Herrera

8 years agoMostly mechanical cleanup of pgbench
Alvaro Herrera [Wed, 27 Jan 2016 01:11:34 +0000 (02:11 +0100)]
Mostly mechanical cleanup of pgbench

pgindent for recent commits; also change some variables from int to
boolean, which is how they are really used.

Mostly submitted by Fabien Coelho; this is in preparation to commit
further patches to the file.

8 years agoFix startup so that log prefix %h works for the log_connections message.
Tom Lane [Tue, 26 Jan 2016 20:38:33 +0000 (15:38 -0500)]
Fix startup so that log prefix %h works for the log_connections message.

We entirely randomly chose to initialize port->remote_host just after
printing the log_connections message, when we could perfectly well do it
just before, allowing %h and %r to work for that message.  Per gripe from
Artem Tomyuk.

8 years agoImprove ResourceOwners' behavior for large numbers of owned objects.
Tom Lane [Tue, 26 Jan 2016 20:20:22 +0000 (15:20 -0500)]
Improve ResourceOwners' behavior for large numbers of owned objects.

The original coding was quite fast so long as objects were always
released in reverse order of addition; otherwise, it degenerated into
O(N^2) behavior due to searching for the array element to delete.
Improve matters by switching to hashed storage when the number of
objects of a given type exceeds 64.  (The cutover point is open to
discussion, of course, but some simple performance testing suggests
that hashing has enough overhead to be a loser below there.)

Also, refactor resowner.c so that we don't need N copies of the array
management code.  Since all the resource IDs the code currently needs
to deal with are either pointers or integers, it seems sufficient to
create a one-size-fits-all infrastructure in which everything is
converted to a Datum for storage.

Aleksander Alekseev, reviewed by Stas Kelvich, further fixes by me

8 years agoVarious fixes to REFRESH MATERIALIZED VIEW tab completion.
Kevin Grittner [Tue, 26 Jan 2016 14:45:08 +0000 (08:45 -0600)]
Various fixes to REFRESH MATERIALIZED VIEW tab completion.

Masahiko Sawada, Fujii Masao, Kevin Grittner

8 years agoRevert "Fix broken multibyte regression tests."
Tatsuo Ishii [Mon, 25 Jan 2016 23:29:15 +0000 (08:29 +0900)]
Revert "Fix broken multibyte regression tests."

This reverts commit efc1610b64b04e7cf08cc1d6c608ede8b7d5ff07.
The commit was plain wrong as pointed out in:
http://www.postgresql.org/message-id/27771.1448736909@sss.pgh.pa.us

8 years agoCorrect comment in GetConflictingVirtualXIDs()
Simon Riggs [Sun, 24 Jan 2016 18:22:11 +0000 (10:22 -0800)]
Correct comment in GetConflictingVirtualXIDs()

We use Share lock because it is safe to do so.

8 years agoYet further adjust degree-based trig functions for more portability.
Tom Lane [Sun, 24 Jan 2016 17:53:03 +0000 (12:53 -0500)]
Yet further adjust degree-based trig functions for more portability.

Buildfarm member cockatiel is still saying that cosd(60) isn't 0.5.
What seems likely is that the subexpression (1.0 - cos(x)) isn't being
rounded to double width before more arithmetic is done on it, so force
that by storing it into a variable.

8 years agoStill further adjust degree-based trig functions for more portability.
Tom Lane [Sat, 23 Jan 2016 23:12:54 +0000 (18:12 -0500)]
Still further adjust degree-based trig functions for more portability.

Indeed, the non-static declaration foreseen in my previous commit message
is necessary.  Per Noah Misch.

8 years agoFurther adjust degree-based trig functions for more portability.
Tom Lane [Sat, 23 Jan 2016 21:17:31 +0000 (16:17 -0500)]
Further adjust degree-based trig functions for more portability.

The last round didn't do it.  Per Noah Misch, the problem on at least
some machines is that the compiler pre-evaluates trig functions having
constant arguments using code slightly different from what will be used
at runtime.  Therefore, we must prevent the compiler from seeing constant
arguments to any of the libm trig functions used in this code.

The method used here might still fail if init_degree_constants() gets
inlined into the call sites.  That probably won't happen given the large
number of call sites; but if it does, we could probably fix it by making
init_degree_constants() non-static.  I'll avoid that till proven
necessary, though.

8 years agoAdjust degree-based trig functions for more portability.
Tom Lane [Sat, 23 Jan 2016 16:26:07 +0000 (11:26 -0500)]
Adjust degree-based trig functions for more portability.

The buildfarm isn't very happy with the results of commit e1bd684a34c11139.
To try to get the expected exact results everywhere:

* Replace M_PI / 180 subexpressions with a precomputed constant, so that
the compiler can't decide to rearrange that division with an adjacent
operation.  Hopefully this will fix failures to get exactly 0.5 from
sind(30) and cosd(60).

* Add scaling to ensure that tand(45) and cotd(45) give exactly 1; there
was nothing particularly guaranteeing that before.

* Replace minus zero by zero when tand() or cotd() would output that;
many machines did so for tand(180) and cotd(270), but not all.  We could
alternatively deem both results valid, but that doesn't seem likely to
be what users will want.

8 years agopsql: Improve completion of FDW DDL commands
Peter Eisentraut [Sat, 23 Jan 2016 11:57:42 +0000 (06:57 -0500)]
psql: Improve completion of FDW DDL commands

Add
- ALTER FOREIGN DATA WRAPPER -> RENAME TO
- ALTER SERVER -> RENAME TO
- ALTER SERVER ... VERSION ... -> OPTIONS
- CREATE FOREIGN DATA WRAPPER -> OPTIONS
- CREATE SERVER -> OPTIONS
- CREATE|ALTER USER MAPPING -> OPTIONS

From: Andreas Karlsson <andreas@proxel.se>

8 years agopg_dump: Fix quoting of domain constraint names
Alvaro Herrera [Fri, 22 Jan 2016 23:04:35 +0000 (20:04 -0300)]
pg_dump: Fix quoting of domain constraint names

The original code was adding double quotes to an already-quoted
identifier, leading to nonsensical results.  Remove the quoting call.

I introduced the broken code in 7eca575d1c of 9.5 era, so backpatch to
9.5.

Report and patch by Elvis Pranskevichus
Reviewed by Michael Paquier

8 years agoAdd trigonometric functions that work in degrees.
Tom Lane [Fri, 22 Jan 2016 20:46:22 +0000 (15:46 -0500)]
Add trigonometric functions that work in degrees.

The implementations go to some lengths to deliver exact results for values
where an exact result can be expected, such as sind(30) = 0.5 exactly.

Dean Rasheed, reviewed by Michael Paquier

8 years agoImprove cross-platform consistency of Inf/NaN handling in trig functions.
Tom Lane [Fri, 22 Jan 2016 19:50:51 +0000 (14:50 -0500)]
Improve cross-platform consistency of Inf/NaN handling in trig functions.

Ensure that the trig functions return NaN for NaN input regardless of what
the underlying C library functions might do.  Also ensure that an error
is thrown for Inf (or otherwise out-of-range) input, except for atan/atan2
which should accept it.

All these behaviors should now conform to the POSIX spec; previously, all
our popular platforms deviated from that in one case or another.

The main remaining platform dependency here is whether the C library might
choose to throw a domain error for sin/cos/tan inputs that are large but
less than infinity.  (Doing so is not unreasonable, since once a single
unit-in-the-last-place exceeds PI, there can be no significance at all in
the result; however there doesn't seem to be any suggestion in POSIX that
such an error is allowed.)  We will report such errors if they are reported
via "errno", but not if they are reported via "fetestexcept" which is the
other mechanism sanctioned by POSIX.  Some preliminary experiments with
fetestexcept indicated that it might also report errors we could do
without, such as complaining about underflow at an unreasonably large
threshold.  So let's skip that complexity for now.

Dean Rasheed, reviewed by Michael Paquier

8 years agoImprove levenshtein() docs.
Tom Lane [Fri, 22 Jan 2016 17:29:07 +0000 (12:29 -0500)]
Improve levenshtein() docs.

Fix chars-vs-bytes confusion here too.  Improve poor grammar and
markup.