Commit Graph

37047 Commits

Author SHA1 Message Date
Tom Lane fa069822f5 More regression test cases for json/jsonb extraction operators.
Cover some cases I omitted before, such as null and empty-string
elements in the path array.  This exposes another inconsistency:
json_extract_path complains about empty path elements but
jsonb_extract_path does not.
2014-08-20 19:05:05 -04:00
Tom Lane 9bac66020d Fix core dump in jsonb #> operator, and add regression test cases.
jsonb's #> operator segfaulted (dereferencing a null pointer) if the RHS
was a zero-length array, as reported in bug #11207 from Justin Van Winkle.
json's #> operator returns NULL in such cases, so for the moment let's
make jsonb act likewise.

Also add a bunch of regression test queries memorializing the -> and #>
operators' behavior for this and other corner cases.

There is a good argument for changing some of these behaviors, as they
are not very consistent with each other, and throwing an error isn't
necessarily a desirable behavior for operators that are likely to be
used in indexes.  However, everybody can agree that a core dump is the
Wrong Thing, and we need test cases even if we decide to change their
expected output later.
2014-08-20 16:48:53 -04:00
Bruce Momjian 7567d94910 pg_upgrade: adjust logging to use QUERY_ALLOC lengths
Allows the logging to print the entire text of failed queries, rather
than a truncated version.
2014-08-20 13:04:45 -04:00
Heikki Linnakangas 02587dcddc Use comma+space as the separator in the default search_path.
While the space is optional, it seems nicer to be consistent with what
you get if you do "SET search_path=...". SET always normalizes the
separator to be comma+space.

Christoph Martin
2014-08-20 12:06:08 +03:00
Fujii Masao c476288653 Revert "Fix bug in checking of IDENTIFY_SYSTEM result."
This reverts commit 083d29c65b.

The commit changed the code so that it causes an errors when
IDENTIFY_SYSTEM returns three columns. But which prevents us
from using the replication-related utilities against the server
with older version. This is not what we want. For that
compatibility, we allow the utilities to receive three columns
as the result of IDENTIFY_SYSTEM eventhough it actually returns
four columns in 9.4 or later.

Pointed out by Andres Freund.
2014-08-19 18:30:38 +09:00
Fujii Masao 083d29c65b Fix bug in checking of IDENTIFY_SYSTEM result.
5a991ef869 added new column into
the result of IDENTIFY_SYSTEM command. But it was not reflected into
several codes checking that result. Specifically though the number of
columns in the result was increased to 4, it was still compared with 3
in some replication codes.

Back-patch to 9.4 where the number of columns in IDENTIFY_SYSTEM
result was increased.

Report from Michael Paquier
2014-08-19 17:26:07 +09:00
Noah Misch 8605bc7521 Install libpq DLL with $(INSTALL_SHLIB).
Programs need execute permission on a DLL file to load it.  MSYS
"install" ignores the mode argument, and our Cygwin build statically
links libpq into programs.  That explains the lack of buildfarm trouble.
Back-patch to 9.0 (all supported versions).
2014-08-18 23:00:38 -04:00
Noah Misch ee9569e4df Finish adding file version information to installed Windows binaries.
In support of this, have the MSVC build follow GNU make in preferring
GNUmakefile over Makefile when a directory contains both.

Michael Paquier, reviewed by MauMau.
2014-08-18 22:59:53 -04:00
Noah Misch fb2aece8ae Replace a few strncmp() calls with strlcpy().
strncmp() is a specialized API unsuited for routine copying into
fixed-size buffers.  On a system where the length of a single filename
can exceed MAXPGPATH, the pg_archivecleanup change prevents a simple
crash in the subsequent strlen().  Few filesystems support names that
long, and calling pg_archivecleanup with untrusted input is still not a
credible use case.  Therefore, no back-patch.

David Rowley
2014-08-18 22:59:31 -04:00
Noah Misch 7fc5f1a355 Make pg_service.conf sample LDIF more portable.
The aboriginal sample placed connection parameters in
groupOfUniqueNames/uniqueMember.  OpenLDAP, at least as early as version
2.4.23, rejects uniqueMember entries that do not conform to the syntax
for a distinguished name.  Use device/description, which is free-form.
Back-patch to 9.4 for web site visibility.
2014-08-18 22:58:57 -04:00
Noah Misch 10718612fb Document new trigger-related forms of ALTER FOREIGN TABLE.
Oversight in commit 7cbe57c34d.
Back-patch to 9.4, where that commit first appeared.  In passing,
release-note the FDW API postcondition change from the same commit.
2014-08-18 22:58:25 -04:00
Greg Stark 663675885e Adjust Release Notes to reflect holding off wrapped expanded mode until 9.5 (thanks Michael Paquier) 2014-08-18 23:12:59 +01:00
Greg Stark 458ef6bad1 Fix further concerns about psql wrapping in expanded mode having
collateral damage on other formats, by Sergey Muraviov.
2014-08-18 12:20:32 +01:00
Heikki Linnakangas 48d50840d5 Reorganize functions in be-secure-openssl.c
Move the functions within the file so that public interface functions come
first, followed by internal functions. Previously, be_tls_write was first,
then internal stuff, and finally the rest of the public interface, which
clearly didn't make much sense.

Per Andres Freund's complaint.
2014-08-18 13:12:40 +03:00
Tom Lane 2b475c5946 Fix obsolete mention of non-int64 support in CREATE SEQUENCE documentation.
The old text explained what happened if we didn't have working int64
arithmetic.  Since that case has been explicitly rejected by configure
since 8.4.3, documenting it in the 9.x branches can only produce confusion.
2014-08-18 01:17:49 -04:00
Tom Lane e56ec50c16 Use ISO 8601 format for dates converted to JSON, too.
Commit f30015b6d7 made this happen for
timestamp and timestamptz, but it seems pretty inconsistent to not
do it for simple dates as well.

(In passing, I re-pgindent'd json.c.)
2014-08-17 22:57:46 -04:00
Fujii Masao 3e9f70f128 Add missing index terms for replication commands in the document.
Previously only CREATE_REPLICATION_SLOT was exposed as an index term.
That's odd and there is no reason not to add index terms for other
replication commands.

Back-patch to 9.4.
2014-08-18 11:19:38 +09:00
Tom Lane f66faadc44 Make an editorial pass over the 9.4 release notes.
Update the notes to include commits through today, and do a lot of
wordsmithing and markup adjustment.  Notably, don't use <link> where <xref>
will do; since we got rid of the text-format HISTORY file, there is no
longer a reason to avoid <xref>.
2014-08-17 22:26:44 -04:00
Tom Lane 259904ecd4 Improve DISCARD documentation.
The new DISCARD SEQUENCES option was inadequately described, and hadn't
been mentioned at all in the initial Description paragraph.  Rather than
rectifying the latter the hard way, it seemed better to rewrite the
description as a summary, instead of having it basically duplicate
statements made under Parameters.  Be more consistent about the ordering
of the options, too.
2014-08-17 15:59:03 -04:00
Peter Eisentraut 1330e2922c doc: Work around stylesheet bug for man build
The upstream stylesheets for man output insert a *roff comment for an
occurrence of an indexterm, for reasons that have apparently been lost
in history.  This, however, is done incorrectly and causes some
formatting problems.  This hasn't been an issue until now, but the
reorganization of indexterm elements inside variablelists has triggered
this issue.

The upstream fix (http://sourceforge.net/p/docbook/bugs/1340/) is to
drop indexterms altogether in man output, and so we'll do the same here.
2014-08-17 09:10:28 -04:00
Tom Lane 737cdc2d14 Fix bogus return macros in range_overright_internal().
PG_RETURN_BOOL() should only be used in functions following the V1 SQL
function API.  This coding accidentally fails to fail since letting the
compiler coerce the Datum representation of bool back to plain bool
does give the right answer; but that doesn't make it a good idea.

Back-patch to older branches just to avoid unnecessary code divergence.
2014-08-16 13:48:39 -04:00
Tom Lane a068b5b65f Add opr_sanity queries to inspect commutator/negator links more closely.
Make lists of the names of all operators that are claimed to be commutator
pairs or negator pairs.  This is analogous to the existing queries that
make lists of all operator names appearing in particular opclass strategy
slots.  Unexpected additions to these lists are likely to be mistakes; had
we had these queries in place before, bug #11178 might've been prevented.
2014-08-16 13:22:52 -04:00
Tom Lane e3f9c16838 Fix bogus commutator/negator links for JSONB containment operators.
<@ and @> are each other's commutators, but they were incorrectly marked
as being each other's negators instead.  (This was actually questioned
in a comment in the original commit, but nobody followed through :-(.)
Per bug #11178 from Christian Pronovost.

In passing, fix some JSONB operator descriptions that were randomly
different from the phrasing of every other similar description.

catversion bump for pg_catalog contents change.
2014-08-16 12:53:54 -04:00
Peter Eisentraut 9ee9ca545b Fix whitespace 2014-08-15 14:52:06 -04:00
Bruce Momjian ea9b8abd6f pg_upgrade: fix define adjusted during testing
from commit e4c3c99ac3
2014-08-15 12:28:18 -04:00
Bruce Momjian e4c3c99ac3 pg_upgrade: error if run from top of new PGDATA on Windows
Print a clear error message in this case, rather than wait for initdb
--sync-only to generate a "Permission denied" error.
2014-08-15 12:04:03 -04:00
Heikki Linnakangas ef153ecc55 Doc fix: New York State's capital is Albany.
The inheritance example in the manual implies that the capital of New York
is New York City, but in reality it's Albany.

George Hartzell
2014-08-15 10:01:31 +03:00
Heikki Linnakangas c07693f0c7 Remove remnants of a JENTRY_ISFIRST flag bit.
I removed the flag earlier, but missed a few references in jsonb.h.
2014-08-15 09:41:28 +03:00
Peter Eisentraut f669b61476 Set shared library path for in-tree TAP tests
When the TAP tests are run in-tree (make check), set the shared library
path using the appropriate environment variable, using a logic similar
to pg_regress, so that the right libraries are used.
2014-08-15 00:01:14 -04:00
Peter Eisentraut d34b48a021 doc: Fix DocBook XML validity
See 3a9d430af5.  A new one snuck in.
2014-08-14 21:47:11 -04:00
Tom Lane 5ff5bfb5f0 Update SysV parameter configuration documentation for FreeBSD.
FreeBSD hasn't made any use of kern.ipc.semmap since 1.1, and newer
releases reject attempts to set it altogether; so stop recommending
that it be adjusted.  Per bug #11161.

Back-patch to all supported branches.  Before 9.3, also incorporate
commit 7a42dff47, which touches the same text and for some reason
was not back-patched at the time.
2014-08-14 16:06:16 -04:00
Robert Haas 751b704105 docs: Add missing period.
Fabien COELHO and Robert Haas
2014-08-14 15:19:43 -04:00
Robert Haas b34e37bfef Add sortsupport routines for text.
This provides a small but worthwhile speedup when sorting text, at least
in cases to which the sortsupport machinery applies.

Robert Haas and Peter Geoghegan
2014-08-14 12:09:52 -04:00
Fujii Masao a4287a689d Fix help message in pg_ctl.
Previously the help message described that -m is an option for
"stop", "restart" and "promote" commands in pg_ctl. But actually
that's not an option for "promote". So this commit fixes that
incorrect description in the help message.

Back-patch to 9.3 where the incorrect description was added.
2014-08-14 13:57:52 +09:00
Peter Eisentraut 5333c72c95 Fix whitespace 2014-08-13 23:15:26 -04:00
Peter Eisentraut 1d678bf7bc Add some noreturn attributes based on compiler recommendations 2014-08-13 22:40:48 -04:00
Peter Eisentraut faa14acc9b doc: Remove obsolete set element DSSSL customizations
We don't use set elements (collection of books) anymore, so this is just
dead code.
2014-08-13 22:10:25 -04:00
Tom Lane a844c29966 Prevent memory leaks in parseRelOptions().
parseRelOptions() tended to leak memory in the caller's context.  Most
of the time this doesn't really matter since the caller's context is
at most query-lifespan, and the function won't be invoked very many times.
However, when testing with CLOBBER_CACHE_RECURSIVELY, the same relcache
entry can get rebuilt a *lot* of times in one query, leading to significant
intraquery memory bloat if it has any reloptions.  Noted while
investigating a related report from Tomas Vondra.

In passing, get rid of some Asserts that are redundant with the one
done by deconstruct_array().

As with other patches to avoid leaks in CLOBBER_CACHE testing, it doesn't
really seem worth back-patching this.
2014-08-13 11:35:51 -04:00
Tom Lane ab8c84db2f Prevent memory leaks in RelationGetIndexList, RelationGetIndexAttrBitmap.
When replacing rd_indexlist, rd_indexattr, etc, we neglected to pfree any
old value of these fields.  Under ordinary circumstances, the old value
would always be NULL, so this seemed reasonable enough.  However, in cases
where we're rebuilding a system catalog's relcache entry and another cache
flush occurs on that same catalog meanwhile, it's possible for the field to
not be NULL when we return to the outer level, because we already refilled
it while recovering from the inner flush.  This leads to a fairly small
session-lifespan leak in CacheMemoryContext.  In real-world usage the leak
would be too small to notice; but in testing with CLOBBER_CACHE_RECURSIVELY
the leakage can add up to the point of causing OOM failures, as reported by
Tomas Vondra.

The issue has been there a long time, but it only seems worth fixing in
HEAD, like the previous fix in this area (commit 078b2ed291).
2014-08-13 11:27:28 -04:00
Fujii Masao 52bffe3499 Expose -S option in pg_receivexlog.
This option is equivalent to --slot option which pg_receivexlog has
already supported, which specifies the replication slot to use for
WAL streaming. pg_recvlogical has already supported both options,
and this commit makes pg_receivexlog consistent with pg_recvlogical
regarding the slot option.

Back-patch to 9.4 where the slot option was added.

Michael Paquier
2014-08-13 10:42:16 +09:00
Andres Freund 596385be06 pg_recvlogical message and code improvements.
Some error messages complained about --init and --stop being used
whereas the --create and --drop are the correct verbs. Fix that.

Also a XLogRecPtr was tested in a boolean fashion instead of being
compared to InvalidXLogRecPtr.

Backpatch to 9.4 where pg_recvlogical was introduced.

Michael Paquier
2014-08-12 13:06:34 +02:00
Fujii Masao d6ded369a7 Fix typo in \setrandom document.
Fabien COELHO
2014-08-12 18:01:01 +09:00
Andres Freund 41d5f8ad73 Be less aggressive in asking for feedback of logical walsender clients.
When doing logical decoding using START_LOGICAL_REPLICATION in a
walsender process the walsender sometimes was sending out keepalive
messages too frequently. Asking for feedback every time.

WalSndWaitForWal() sends out keepalive messages when it's waiting for
new WAL to be generated locally when it sees that the remote side
hasn't yet flushed WAL up to the local position. That generally is
good but causes problems if the remote side only writes but doesn't
flush changes yet. So check for both remote write and flush position.

Additionally we've asked for feedback to the keepalive message which
isn't warranted when waiting for WAL in contrast to preventing
timeouts because of wal_sender_timeout.

Complaint and patch by Steve Singer.
2014-08-12 11:04:50 +02:00
Tatsuo Ishii 51222a1766 Enhance pgbench's option checking.
Now benchmarking options such as -c cannot be used if initializing
option (-i) is specified.  Also initializing options such as -F cannot
be used if initializing option is not specified.

Tatsuo Ishii and Fabien COELHO.
2014-08-12 17:27:08 +09:00
Fujii Masao 3e3f65973a Change first call of ProcessConfigFile so as to process only data_directory.
When both postgresql.conf and postgresql.auto.conf have their own entry of
the same parameter, PostgreSQL uses the entry in postgresql.auto.conf because
it appears last in the configuration scan. IOW, the other entries which appear
earlier are ignored. But, previously, ProcessConfigFile() detected the invalid
settings of even those unused entries and emitted the error messages
complaining about them, at postmaster startup. Complaining about the entries
to ignore is basically useless.

This problem happened because ProcessConfigFile() was called twice at
postmaster startup and the first call read only postgresql.conf. That is, the
first call could check the entry which might be ignored eventually by
the second call which read both postgresql.conf and postgresql.auto.conf.
To work around the problem, this commit changes ProcessConfigFile so that
its first call processes only data_directory and the second one does all the
entries. It's OK to process data_directory in the first call because it's
ensured that data_directory doesn't exist in postgresql.auto.conf.

Back-patch to 9.4 where postgresql.auto.conf was added.

Patch by me. Review by Amit Kapila
2014-08-12 16:50:09 +09:00
Fujii Masao e15c4ab5fb Add tab-completion for \unset and valid setting values of psql variables.
This commit also changes tab-completion for \set so that it displays
all the special variables like COMP_KEYWORD_CASE. Previously it displayed
only variables having the set values. Which was not user-friendly for
those who want to set the unset variables.

This commit also changes tab-completion for :variable so that only the
variables having the set values are displayed. Previously even unset
variables were displayed.

Pavel Stehule, modified by me.
2014-08-12 11:57:39 +09:00
Fujii Masao 7d835ff4db Fix documentation oversights about pageinspect and initialization fork.
The initialization fork was added in 9.1, but has not been taken into
consideration in documents of get_raw_page function in pageinspect and
storage layout. This commit fixes those oversights.

get_raw_page can read not only a table but also an index, etc. So it
should be documented that the function can read any relation. This commit
also fixes the document of pageinspect that way.

Back-patch to 9.1 where those oversights existed.

Vik Fearing, review by MauMau
2014-08-11 22:52:16 +09:00
Heikki Linnakangas 680513ab79 Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.

The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.

Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 11:54:19 +03:00
Tom Lane 6aa61580e0 Clarify type resolution behavior for domain types.
The user documentation was vague and not entirely accurate about how
we treat domain inputs for ambiguous operators/functions.  Clarify
that, and add an example and some commentary.  Per a recent question
from Adam Mackler.

It's acted like this ever since we added domains, so back-patch
to all supported branches.
2014-08-10 16:13:13 -04:00
Tom Lane 92f57c9ae9 Clean up handling of unknown-type inputs in json_build_object and friends.
There's actually no need for any special case for unknown-type literals,
since we only need to push the value through its output function and
unknownout() works fine.  The code that was here was completely bizarre
anyway, and would fail outright in cases that should work, not to mention
suffering from some copy-and-paste bugs.
2014-08-09 17:31:13 -04:00