]> granicus.if.org Git - postgresql/log
postgresql
9 years agoDon't hardcode contrib_regression dbname in postgres_fdw and dblink tests.
Andres Freund [Tue, 26 Aug 2014 00:54:53 +0000 (02:54 +0200)]
Don't hardcode contrib_regression dbname in postgres_fdw and dblink tests.

That allows parallel installcheck to succeed inside contrib/. The
output is not particularly pretty unless make's -O option to
synchronize the output is used.

There's other tests, outside contrib, that use a hardcoded,
non-unique, database name. Those prohibit paralell installcheck to be
used across more directories; but that's something for a separate
patch.

9 years agoShow schema names in pg_dump verbose output.
Heikki Linnakangas [Tue, 26 Aug 2014 08:50:48 +0000 (11:50 +0300)]
Show schema names in pg_dump verbose output.

Fabrízio de Royes Mello, reviewed by Michael Paquier

9 years agopg_upgrade: prevent automatic oid assignment
Bruce Momjian [Tue, 26 Aug 2014 02:19:05 +0000 (22:19 -0400)]
pg_upgrade:  prevent automatic oid assignment

Prevent automatic oid assignment when in binary upgrade mode.  Also
throw an error when contrib/pg_upgrade_support functions are called when
not in binary upgrade mode.

This prevent automatically-assigned oids from conflicting with later
pre-assigned oids coming from the old cluster.  It also makes sure oids
are preserved in call important cases.

9 years agorename macro isTempOrToastNamespace to isTempOrTempToastNamespace
Bruce Momjian [Tue, 26 Aug 2014 01:28:19 +0000 (21:28 -0400)]
rename macro isTempOrToastNamespace to isTempOrTempToastNamespace

Done for clarity

9 years agopg_upgrade: use CTE query rather than temp table
Bruce Momjian [Tue, 26 Aug 2014 01:22:08 +0000 (21:22 -0400)]
pg_upgrade:  use CTE query rather than temp table

Now that 8.3 is not supported, we can use a CTE and not temp tables.
This allows for auto-oid assignment protection in a future patch.

9 years agopg_upgrade docs: update docs for 8.3 support removal
Bruce Momjian [Tue, 26 Aug 2014 00:11:48 +0000 (20:11 -0400)]
pg_upgrade docs:  update docs for 8.3 support removal

9 years agorevert "Throw error for ALTER TABLE RESET of an invalid option"
Bruce Momjian [Tue, 26 Aug 2014 00:07:37 +0000 (20:07 -0400)]
revert "Throw error for ALTER TABLE RESET of an invalid option"

Reverts commits 73d78e11a0f7183c80b93eefbbb6026fe9664015 and
b0488e5c4fbfdce8acc989bdc17d9f0ec09ac281.  Also reverts pg_upgrade
changes.

9 years agopg_upgrade: remove support for 8.3 old clusters
Bruce Momjian [Tue, 26 Aug 2014 00:05:07 +0000 (20:05 -0400)]
pg_upgrade:  remove support for 8.3 old clusters

This trims down the code, and is in preparation for hardening pg_upgrade
against auto-oid assignment.

9 years agopg_upgrade: add SET log_min_error_statement = warning
Bruce Momjian [Mon, 25 Aug 2014 21:24:33 +0000 (17:24 -0400)]
pg_upgrade:  add SET log_min_error_statement = warning

Add to commit 73d78e11a0f7183c80b93eefbbb6026fe9664015

9 years agoThrow error for ALTER TABLE RESET of an invalid option
Bruce Momjian [Mon, 25 Aug 2014 21:06:40 +0000 (17:06 -0400)]
Throw error for ALTER TABLE RESET of an invalid option

Also adjust pg_upgrade to not use this method for optional TOAST table
creation.

Patch by Fabrízio de Royes Mello

9 years agopg_ctl, pg_upgrade: allow multiple -o/-O options, append them
Bruce Momjian [Mon, 25 Aug 2014 20:30:26 +0000 (16:30 -0400)]
pg_ctl, pg_upgrade:  allow multiple -o/-O options, append them

Report by Pavel Raiskup

9 years agoupgrade docs: highlight pg_upgrade, warn about globals preservation
Bruce Momjian [Mon, 25 Aug 2014 19:34:51 +0000 (15:34 -0400)]
upgrade docs:  highlight pg_upgrade, warn about globals preservation

Also, remove OID preservation mention, mention non-text dump formats

Backpatch through 9.4

9 years agoRevert XactLockTableWait context setup in conditional multixact wait
Alvaro Herrera [Mon, 25 Aug 2014 19:33:17 +0000 (15:33 -0400)]
Revert XactLockTableWait context setup in conditional multixact wait

There's no point in setting up a context error callback when doing
conditional lock acquisition, because we never actually wait and so the
user wouldn't be able to see the context message anywhere.  In fact,
this is more in line with what ConditionalXactLockTableWait is doing.

Backpatch to 9.4, where this was added.

9 years agoUse newly added InvalidCommandId instead of 0
Alvaro Herrera [Mon, 25 Aug 2014 19:32:30 +0000 (15:32 -0400)]
Use newly added InvalidCommandId instead of 0

The symbol was added by 71901ab6d; the original code was introduced by
6868ed749.  Development of both overlapped which is why we apparently
failed to notice.

This is a (very slight) behavior change, so I'm not backpatching this to
9.4 for now, even though the symbol does exist there.

9 years agoDefineType: return base type OID, not its array
Alvaro Herrera [Mon, 25 Aug 2014 19:32:26 +0000 (15:32 -0400)]
DefineType: return base type OID, not its array

Event triggers want to know the OID of the interesting object created,
which is the main type.  The array created as part of the operation is
just a subsidiary object which is not of much interest.

9 years agoHave CREATE TABLE AS and REFRESH return an OID
Alvaro Herrera [Mon, 25 Aug 2014 19:32:18 +0000 (15:32 -0400)]
Have CREATE TABLE AS and REFRESH return an OID

Other DDL commands are already returning the OID, which is required for
future additional event trigger work.  This is merely making these
commands in line with the rest of utility command support.

9 years agoMore psprintf goodness
Alvaro Herrera [Mon, 25 Aug 2014 19:32:15 +0000 (15:32 -0400)]
More psprintf goodness

9 years agoOops, forgot to "git add" one last change
Alvaro Herrera [Mon, 25 Aug 2014 19:32:06 +0000 (15:32 -0400)]
Oops, forgot to "git add" one last change

9 years agoEditorial review of SET UNLOGGED
Alvaro Herrera [Mon, 25 Aug 2014 17:50:19 +0000 (13:50 -0400)]
Editorial review of SET UNLOGGED

Add a succint comment explaining why it's correct to change the
persistence in this way.  Also s/loggedness/persistence/ because native
speakers didn't like the latter term.

Fabrízio and Álvaro

9 years agoAdd regression tests for SELECT FOR UPDATE/SHARE NOWAIT.
Heikki Linnakangas [Mon, 25 Aug 2014 17:12:01 +0000 (20:12 +0300)]
Add regression tests for SELECT FOR UPDATE/SHARE NOWAIT.

Thomas Munro

9 years agoFix typos in some error messages thrown by extension scripts when fed to psql.
Andres Freund [Mon, 25 Aug 2014 16:30:37 +0000 (18:30 +0200)]
Fix typos in some error messages thrown by extension scripts when fed to psql.

Some of the many error messages introduced in 458857cc missed 'FROM
unpackaged'. Also e016b724 and 45ffeb7e forgot to quote extension
version numbers.

Backpatch to 9.1, just like 458857cc which introduced the messages. Do
so because the error messages thrown when the wrong command is copy &
pasted aren't easy to understand.

9 years agoDon't track DEALLOCATE in pg_stat_statements.
Heikki Linnakangas [Mon, 25 Aug 2014 16:13:24 +0000 (19:13 +0300)]
Don't track DEALLOCATE in pg_stat_statements.

We also don't track PREPARE, nor do we track planning time in general, so
let's ignore DEALLOCATE as well for consistency.

Backpatch to 9.4, but not further than that. Although it seems unlikely that
anyone is relying on the current behavior, this is a behavioral change.

Fabien Coelho

9 years agoFix another ancient memory-leak bug in relcache.c.
Tom Lane [Sun, 24 Aug 2014 15:56:52 +0000 (11:56 -0400)]
Fix another ancient memory-leak bug in relcache.c.

CheckConstraintFetch() leaked a cstring in the caller's context for each
CHECK constraint expression it copied into the relcache.  Ordinarily that
isn't problematic, but it can be during CLOBBER_CACHE testing because so
many reloads can happen during a single query; so complicate the code
slightly to allow freeing the cstring after use.  Per testing on buildfarm
member barnacle.

This is exactly like the leak fixed in AttrDefaultFetch() by commit
078b2ed291c758e7125d72c3a235f128d40a232b.  (Yes, this time I did look for
other instances of the same coding pattern :-(.)  Like that patch, no
back-patch, since it seems unlikely that there's any problem except under
very artificial test conditions.

BTW, it strikes me that both of these places would require further work
comparable to commit ab8c84db2f7af008151b848cf1d6a4672a39eecd, if we ever
supported defaults or check constraints on system catalogs: they both
assume they are copying into an empty relcache data structure, and that
conceivably wouldn't be the case during recursive reloading of a system
catalog.  This does not seem worth worrying about for the moment, since
there is no near-term prospect of supporting any such thing.  So I'll
just note the possibility for the archives' sake.

9 years agodoc: Improve pg_restore help output
Peter Eisentraut [Sat, 23 Aug 2014 04:23:34 +0000 (00:23 -0400)]
doc: Improve pg_restore help output

Add a note that some options can be specified multiple times to select
multiple objects to restore.  This replaces the somewhat confusing use
of plurals in the option descriptions themselves.

9 years agoImplement ALTER TABLE .. SET LOGGED / UNLOGGED
Alvaro Herrera [Fri, 22 Aug 2014 18:27:00 +0000 (14:27 -0400)]
Implement ALTER TABLE .. SET LOGGED / UNLOGGED

This enables changing permanent (logged) tables to unlogged and
vice-versa.

(Docs for ALTER TABLE / SET TABLESPACE got shuffled in an order that
hopefully makes more sense than the original.)

Author: Fabrízio de Royes Mello
Reviewed by: Christoph Berg, Andres Freund, Thom Brown
Some tweaking by Álvaro Herrera

9 years agoFix outdated comment
Alvaro Herrera [Fri, 22 Aug 2014 17:55:34 +0000 (13:55 -0400)]
Fix outdated comment

9 years agoFix corner-case behaviors in JSON/JSONB field extraction operators.
Tom Lane [Fri, 22 Aug 2014 17:17:58 +0000 (13:17 -0400)]
Fix corner-case behaviors in JSON/JSONB field extraction operators.

Cause the path extraction operators to return their lefthand input,
not NULL, if the path array has no elements.  This seems more consistent
since the case ought to correspond to applying the simple extraction
operator (->) zero times.

Cause other corner cases in field/element/path extraction to return NULL
rather than failing.  This behavior is arguably more useful than throwing
an error, since it allows an expression index using these operators to be
built even when not all values in the column are suitable for the
extraction being indexed.  Moreover, we already had multiple
inconsistencies between the path extraction operators and the simple
extraction operators, as well as inconsistencies between the JSON and
JSONB code paths.  Adopt a uniform rule of returning NULL rather than
throwing an error when the JSON input does not have a structure that
permits the request to be satisfied.

Back-patch to 9.4.  Update the release notes to list this as a behavior
change since 9.3.

9 years agoFix newly introduced misspelling of existence in pg_buffercache.
Andres Freund [Fri, 22 Aug 2014 07:25:47 +0000 (09:25 +0200)]
Fix newly introduced misspelling of existence in pg_buffercache.

Peter Geoghegan

9 years agoFix comment in pg_basebackup.
Heikki Linnakangas [Fri, 22 Aug 2014 10:45:38 +0000 (13:45 +0300)]
Fix comment in pg_basebackup.

The option is called --tablespace-mapping, not --tablespace.

Amit Kapila

9 years agoChange the way pg_basebackup's tablespace mapping is implemented.
Heikki Linnakangas [Fri, 22 Aug 2014 07:16:26 +0000 (10:16 +0300)]
Change the way pg_basebackup's tablespace mapping is implemented.

Previously, we would first create the symlinks the way they are in the
original system, and at the end replace them with the mapped symlinks.
That never really made much sense, so now we create the symlink pointing
to the correct location to begin with, so that there's no need to fix
them at the end.

The old coding didn't work correctly on Windows, because Windows junction
points look more like directories than files, and ought to be removed with
rmdir rather than unlink. Also, it incorrectly used "%d" rather than "%u"
to print an Oid, but that's gone now.

Report and patch by Amit Kapila, with minor changes by me. Reviewed by
MauMau. Backpatch to 9.4, where the --tablespace feature was added.

9 years agoFix whitespace
Peter Eisentraut [Fri, 22 Aug 2014 01:37:41 +0000 (21:37 -0400)]
Fix whitespace

9 years agoRework 'MOVE ALL' to 'ALTER .. ALL IN TABLESPACE'
Stephen Frost [Thu, 21 Aug 2014 23:06:17 +0000 (19:06 -0400)]
Rework 'MOVE ALL' to 'ALTER .. ALL IN TABLESPACE'

As 'ALTER TABLESPACE .. MOVE ALL' really didn't change the tablespace
but instead changed objects inside tablespaces, it made sense to
rework the syntax and supporting functions to operate under the
'ALTER (TABLE|INDEX|MATERIALIZED VIEW)' syntax and to be in
tablecmds.c.

Pointed out by Alvaro, who also suggested the new syntax.

Back-patch to 9.4.

9 years agoAdd pinning_backends column to the pg_buffercache extension.
Andres Freund [Thu, 21 Aug 2014 22:28:37 +0000 (00:28 +0200)]
Add pinning_backends column to the pg_buffercache extension.

The new column shows how many backends have a buffer pinned. That can
be useful during development or to diagnose production issues
e.g. caused by vacuum waiting for cleanup locks.

To handle upgrades transparently - the extension might be used in
views - deal with callers expecting the old number of columns.

Reviewed by Fujii Masao and Rajeev rastogi.

9 years agoAdd #define INT64_MODIFIER for the printf length modifier for 64-bit ints.
Heikki Linnakangas [Thu, 21 Aug 2014 06:56:44 +0000 (09:56 +0300)]
Add #define INT64_MODIFIER for the printf length modifier for 64-bit ints.

We have had INT64_FORMAT and UINT64_FORMAT for a long time, but that's not
good enough if you want something more exotic, like "%20lld".

Abhijit Menon-Sen, per Andres Freund's suggestion.

9 years agoMore regression test cases for json/jsonb extraction operators.
Tom Lane [Wed, 20 Aug 2014 23:05:05 +0000 (19:05 -0400)]
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.

9 years agoFix core dump in jsonb #> operator, and add regression test cases.
Tom Lane [Wed, 20 Aug 2014 20:48:35 +0000 (16:48 -0400)]
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.

9 years agopg_upgrade: adjust logging to use QUERY_ALLOC lengths
Bruce Momjian [Wed, 20 Aug 2014 17:03:58 +0000 (13:03 -0400)]
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.

9 years agoUse comma+space as the separator in the default search_path.
Heikki Linnakangas [Wed, 20 Aug 2014 09:04:32 +0000 (12:04 +0300)]
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

9 years agoRevert "Fix bug in checking of IDENTIFY_SYSTEM result."
Fujii Masao [Tue, 19 Aug 2014 09:30:38 +0000 (18:30 +0900)]
Revert "Fix bug in checking of IDENTIFY_SYSTEM result."

This reverts commit 083d29c65b7897f90c70e6dc0a4240a5fa75c8f2.

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.

9 years agoFix bug in checking of IDENTIFY_SYSTEM result.
Fujii Masao [Tue, 19 Aug 2014 08:26:07 +0000 (17:26 +0900)]
Fix bug in checking of IDENTIFY_SYSTEM result.

5a991ef8692ed0d170b44958a81a6bd70e90585 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

9 years agoInstall libpq DLL with $(INSTALL_SHLIB).
Noah Misch [Tue, 19 Aug 2014 03:00:38 +0000 (23:00 -0400)]
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).

9 years agoFinish adding file version information to installed Windows binaries.
Noah Misch [Tue, 19 Aug 2014 02:59:53 +0000 (22:59 -0400)]
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.

9 years agoReplace a few strncmp() calls with strlcpy().
Noah Misch [Tue, 19 Aug 2014 02:59:31 +0000 (22:59 -0400)]
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

9 years agoMake pg_service.conf sample LDIF more portable.
Noah Misch [Tue, 19 Aug 2014 02:58:57 +0000 (22:58 -0400)]
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.

9 years agoDocument new trigger-related forms of ALTER FOREIGN TABLE.
Noah Misch [Tue, 19 Aug 2014 02:58:25 +0000 (22:58 -0400)]
Document new trigger-related forms of ALTER FOREIGN TABLE.

Oversight in commit 7cbe57c34dec4860243e6d0f81738cfbb6e5d069.
Back-patch to 9.4, where that commit first appeared.  In passing,
release-note the FDW API postcondition change from the same commit.

9 years agoAdjust Release Notes to reflect holding off wrapped expanded mode until 9.5 (thanks...
Greg Stark [Mon, 18 Aug 2014 22:12:59 +0000 (23:12 +0100)]
Adjust Release Notes to reflect holding off wrapped expanded mode until 9.5 (thanks Michael Paquier)

9 years agoFix further concerns about psql wrapping in expanded mode having
Greg Stark [Mon, 18 Aug 2014 11:06:11 +0000 (12:06 +0100)]
Fix further concerns about psql wrapping in expanded mode having
collateral damage on other formats, by Sergey Muraviov.

9 years agoReorganize functions in be-secure-openssl.c
Heikki Linnakangas [Mon, 18 Aug 2014 10:04:47 +0000 (13:04 +0300)]
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.

9 years agoFix obsolete mention of non-int64 support in CREATE SEQUENCE documentation.
Tom Lane [Mon, 18 Aug 2014 05:17:49 +0000 (01:17 -0400)]
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.

9 years agoUse ISO 8601 format for dates converted to JSON, too.
Tom Lane [Mon, 18 Aug 2014 02:57:15 +0000 (22:57 -0400)]
Use ISO 8601 format for dates converted to JSON, too.

Commit f30015b6d794c15d52abbb3df3a65081fbefb1ed 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.)

9 years agoAdd missing index terms for replication commands in the document.
Fujii Masao [Mon, 18 Aug 2014 02:18:53 +0000 (11:18 +0900)]
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.

9 years agoMake an editorial pass over the 9.4 release notes.
Tom Lane [Mon, 18 Aug 2014 02:26:44 +0000 (22:26 -0400)]
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>.

9 years agoImprove DISCARD documentation.
Tom Lane [Sun, 17 Aug 2014 19:59:03 +0000 (15:59 -0400)]
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.

9 years agodoc: Work around stylesheet bug for man build
Peter Eisentraut [Sun, 17 Aug 2014 13:10:28 +0000 (09:10 -0400)]
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.

9 years agoFix bogus return macros in range_overright_internal().
Tom Lane [Sat, 16 Aug 2014 17:48:39 +0000 (13:48 -0400)]
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.

9 years agoAdd opr_sanity queries to inspect commutator/negator links more closely.
Tom Lane [Sat, 16 Aug 2014 17:22:52 +0000 (13:22 -0400)]
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.

9 years agoFix bogus commutator/negator links for JSONB containment operators.
Tom Lane [Sat, 16 Aug 2014 16:53:54 +0000 (12:53 -0400)]
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.

9 years agoFix whitespace
Peter Eisentraut [Fri, 15 Aug 2014 18:52:06 +0000 (14:52 -0400)]
Fix whitespace

9 years agopg_upgrade: fix define adjusted during testing
Bruce Momjian [Fri, 15 Aug 2014 16:28:18 +0000 (12:28 -0400)]
pg_upgrade:  fix define adjusted during testing

from commit e4c3c99ac3d4777458ef3e94b037438b244b72b6

9 years agopg_upgrade: error if run from top of new PGDATA on Windows
Bruce Momjian [Fri, 15 Aug 2014 16:03:49 +0000 (12:03 -0400)]
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.

9 years agoDoc fix: New York State's capital is Albany.
Heikki Linnakangas [Fri, 15 Aug 2014 06:57:46 +0000 (09:57 +0300)]
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

9 years agoRemove remnants of a JENTRY_ISFIRST flag bit.
Heikki Linnakangas [Fri, 15 Aug 2014 06:39:38 +0000 (09:39 +0300)]
Remove remnants of a JENTRY_ISFIRST flag bit.

I removed the flag earlier, but missed a few references in jsonb.h.

9 years agoSet shared library path for in-tree TAP tests
Peter Eisentraut [Fri, 15 Aug 2014 04:01:14 +0000 (00:01 -0400)]
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.

9 years agodoc: Fix DocBook XML validity
Peter Eisentraut [Fri, 15 Aug 2014 01:47:11 +0000 (21:47 -0400)]
doc: Fix DocBook XML validity

See 3a9d430af515e9dd8a9d34a4011367e667a66521.  A new one snuck in.

9 years agoUpdate SysV parameter configuration documentation for FreeBSD.
Tom Lane [Thu, 14 Aug 2014 20:05:46 +0000 (16:05 -0400)]
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.

9 years agodocs: Add missing period.
Robert Haas [Thu, 14 Aug 2014 19:19:43 +0000 (15:19 -0400)]
docs: Add missing period.

Fabien COELHO and Robert Haas

9 years agoAdd sortsupport routines for text.
Robert Haas [Thu, 14 Aug 2014 16:09:52 +0000 (12:09 -0400)]
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

9 years agoFix help message in pg_ctl.
Fujii Masao [Thu, 14 Aug 2014 04:57:52 +0000 (13:57 +0900)]
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.

9 years agoFix whitespace
Peter Eisentraut [Thu, 14 Aug 2014 03:15:26 +0000 (23:15 -0400)]
Fix whitespace

9 years agoAdd some noreturn attributes based on compiler recommendations
Peter Eisentraut [Thu, 14 Aug 2014 02:40:48 +0000 (22:40 -0400)]
Add some noreturn attributes based on compiler recommendations

9 years agodoc: Remove obsolete set element DSSSL customizations
Peter Eisentraut [Thu, 14 Aug 2014 02:10:25 +0000 (22:10 -0400)]
doc: Remove obsolete set element DSSSL customizations

We don't use set elements (collection of books) anymore, so this is just
dead code.

9 years agoPrevent memory leaks in parseRelOptions().
Tom Lane [Wed, 13 Aug 2014 15:35:51 +0000 (11:35 -0400)]
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.

9 years agoPrevent memory leaks in RelationGetIndexList, RelationGetIndexAttrBitmap.
Tom Lane [Wed, 13 Aug 2014 15:27:28 +0000 (11:27 -0400)]
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 078b2ed291c758e7).

9 years agoExpose -S option in pg_receivexlog.
Fujii Masao [Wed, 13 Aug 2014 01:42:16 +0000 (10:42 +0900)]
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

9 years agopg_recvlogical message and code improvements.
Andres Freund [Tue, 12 Aug 2014 09:12:16 +0000 (11:12 +0200)]
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

9 years agoFix typo in \setrandom document.
Fujii Masao [Tue, 12 Aug 2014 09:01:01 +0000 (18:01 +0900)]
Fix typo in \setrandom document.

Fabien COELHO

9 years agoBe less aggressive in asking for feedback of logical walsender clients.
Andres Freund [Tue, 12 Aug 2014 09:04:50 +0000 (11:04 +0200)]
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.

9 years agoEnhance pgbench's option checking.
Tatsuo Ishii [Tue, 12 Aug 2014 08:27:08 +0000 (17:27 +0900)]
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.

9 years agoChange first call of ProcessConfigFile so as to process only data_directory.
Fujii Masao [Tue, 12 Aug 2014 07:50:09 +0000 (16:50 +0900)]
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

9 years agoAdd tab-completion for \unset and valid setting values of psql variables.
Fujii Masao [Tue, 12 Aug 2014 02:57:39 +0000 (11:57 +0900)]
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.

9 years agoFix documentation oversights about pageinspect and initialization fork.
Fujii Masao [Mon, 11 Aug 2014 13:52:16 +0000 (22:52 +0900)]
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

9 years agoBreak out OpenSSL-specific code to separate files.
Heikki Linnakangas [Mon, 11 Aug 2014 08:54:19 +0000 (11:54 +0300)]
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.

9 years agoClarify type resolution behavior for domain types.
Tom Lane [Sun, 10 Aug 2014 20:13:13 +0000 (16:13 -0400)]
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.

9 years agoClean up handling of unknown-type inputs in json_build_object and friends.
Tom Lane [Sat, 9 Aug 2014 21:31:13 +0000 (17:31 -0400)]
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.

9 years agoFurther cleanup of JSON-specific error messages.
Tom Lane [Sat, 9 Aug 2014 20:35:29 +0000 (16:35 -0400)]
Further cleanup of JSON-specific error messages.

Fix an obvious typo in json_build_object()'s complaint about invalid
number of arguments, and make the errhint a bit more sensible too.

Per discussion about how to word the improved hint, change the few places
in the documentation that refer to JSON object field names as "names" to
say "keys" instead, since that's what we've said in the vast majority of
places in the docs.  Arguably "name" is more correct, since that's the
terminology used in RFC 7159; but we're stuck with "key" in view of the
naming of json_object_keys() so let's at least be self-consistent.

I adjusted a few code comments to match this as well, and failed to
resist the temptation to clean up some odd whitespace choices in the
same area, as well as a useless duplicate PG_ARGISNULL() check.  There's
still quite a bit of code that uses the phrase "field name" in non-user-
visible ways, so I left those usages alone.

9 years agoReject duplicate column names in foreign key referenced-columns lists.
Tom Lane [Sat, 9 Aug 2014 17:46:34 +0000 (13:46 -0400)]
Reject duplicate column names in foreign key referenced-columns lists.

Such cases are disallowed by the SQL spec, and even if we wanted to allow
them, the semantics seem ambiguous: how should the FK columns be matched up
with the columns of a unique index?  (The matching could be significant in
the presence of opclasses with different notions of equality, so this issue
isn't just academic.)  However, our code did not previously reject such
cases, but instead would either fail to match to any unique index, or
generate a bizarre opclass-lookup error because of sloppy thinking in the
index-matching code.

David Rowley

9 years agoSmall message fixes
Peter Eisentraut [Sat, 9 Aug 2014 04:07:00 +0000 (00:07 -0400)]
Small message fixes

9 years agoAdd -F option to pg_receivexlog, for specifying fsync interval.
Fujii Masao [Fri, 8 Aug 2014 07:50:54 +0000 (16:50 +0900)]
Add -F option to pg_receivexlog, for specifying fsync interval.

This allows us to specify the maximum time to issue fsync to ensure
the received WAL file is safely flushed to disk. Without this,
pg_receivexlog always flushes WAL file only when it's closed and
which can cause WAL data to be lost at the event of a crash.

Furuya Osamu, heavily modified by me.

9 years agoFix typo in docs.
Tom Lane [Fri, 8 Aug 2014 00:46:41 +0000 (20:46 -0400)]
Fix typo in docs.

s/XIDs XIDs/XIDs/ in one place in maintenance.sgml.

Guillaume Lelarge

9 years agopg_upgrade: prevent oid conflicts with new-cluster TOAST tables
Bruce Momjian [Thu, 7 Aug 2014 18:56:13 +0000 (14:56 -0400)]
pg_upgrade: prevent oid conflicts with new-cluster TOAST tables

Previously, TOAST tables only required in the new cluster could cause
oid conflicts if they were auto-numbered and a later conflicting oid had
to be assigned.

Backpatch through 9.3

9 years agoImprove comment.
Heikki Linnakangas [Thu, 7 Aug 2014 09:38:16 +0000 (12:38 +0300)]
Improve comment.

Based on the old comment, it took me a while to figure out what the
problem was. The importnat detail is that SSL_read() can return WANT_READ
even though some raw data was received from the socket.

9 years agoAdd PG_RETURN_UINT16 macro.
Robert Haas [Wed, 6 Aug 2014 20:11:43 +0000 (16:11 -0400)]
Add PG_RETURN_UINT16 macro.

Manuel Kniep

9 years agoDon't require sort support functions to provide a comparator.
Robert Haas [Wed, 6 Aug 2014 20:06:06 +0000 (16:06 -0400)]
Don't require sort support functions to provide a comparator.

This could be useful for datatypes like text, where we might want
to optimize for some collations but not others.  However, this patch
doesn't introduce any new sortsupport functions that work this way;
it merely revises the code so that future patches may do so.

Patch by me.  Review by Peter Geoghegan.

9 years agoFix alternate regression test output file.
Robert Haas [Wed, 6 Aug 2014 15:18:38 +0000 (11:18 -0400)]
Fix alternate regression test output file.

Commit 0ef99bdce3a6cd3195d7df12093042c16328c71c broke this.

Jeff Janes

9 years agoRefactor pg_receivexlog main loop code, for readability, take 2.
Fujii Masao [Wed, 6 Aug 2014 11:58:13 +0000 (20:58 +0900)]
Refactor pg_receivexlog main loop code, for readability, take 2.

Previously the source codes for processing the received data and handling
the end of stream were included in pg_receivexlog main loop. This commit
splits out them as separate functions. This is useful for improving the
readability of main loop code and making the future pg_receivexlog-related
patch simpler.

9 years agoChange ParseConfigFp() so that it doesn't process unused entry of each parameter.
Fujii Masao [Wed, 6 Aug 2014 05:49:43 +0000 (14:49 +0900)]
Change ParseConfigFp() so that it doesn't process unused entry of each parameter.

When more than one setting entries of same parameter exist in the
configuration file, PostgreSQL uses only entry appearing last in
configuration file scan. Since the other entries are not used,
ParseConfigFp() doesn't need to process them, but previously it did
that. This problematic behavior caused the configuration file scan
to detect invalid settings of unused entries (e.g., existence of
multiple entries of PGC_POSTMASTER parameter) and log the messages
complaining about them.

This commit changes the configuration file scan so that it processes
only last entry of each parameter.

Note that when multiple entries of same parameter exist both in
postgresql.conf and postgresql.auto.conf, unused entries in
postgresql.conf are still processed only at postmaster startup.

The problem has existed since old version, but a user is more likely
to encounter it since 9.4 where ALTER SYSTEM command was introduced.
So back-patch to 9.4.

Amit Kapila, slightly modified by me. Per report from Christoph Berg.

9 years agoFix typo in C comment.
Kevin Grittner [Tue, 5 Aug 2014 19:17:21 +0000 (14:17 -0500)]
Fix typo in C comment.

9 years agoImprove some JSON error messages.
Robert Haas [Tue, 5 Aug 2014 16:26:25 +0000 (12:26 -0400)]
Improve some JSON error messages.

These messages are new in 9.4, which hasn't been released yet, so
back-patch to REL9_4_STABLE.

Daniele Varrazzo

9 years agopg_upgrade: assume user is install user
Bruce Momjian [Mon, 4 Aug 2014 15:56:16 +0000 (11:56 -0400)]
pg_upgrade:  assume user is install user

The user specified to the upgrade was effectively the install user, but
that was not clearly stated in the comments, documentation, or error
messages.

9 years agopg_upgrade: remove reference to autovacuum_multixact_freeze_max_age
Bruce Momjian [Mon, 4 Aug 2014 15:45:45 +0000 (11:45 -0400)]
pg_upgrade:  remove reference to autovacuum_multixact_freeze_max_age

autovacuum_multixact_freeze_max_age was added as a pg_ctl start
parameter in 9.3.X to prevent autovacuum from running.  However, only
some 9.3.X releases have autovacuum_multixact_freeze_max_age as it was
added in a minor PG 9.3 release.  It also isn't needed because -b turns
off autovacuum in 9.1+.

Without this fix, trying to upgrade from an early 9.3 release to 9.4
would fail.

Report by EDB

Backpatch through 9.3