]> granicus.if.org Git - postgresql/log
postgresql
9 years agodoc: Improve ALTER VIEW / SET documentation
Peter Eisentraut [Tue, 14 Oct 2014 02:17:34 +0000 (22:17 -0400)]
doc: Improve ALTER VIEW / SET documentation

The way the ALTER VIEW / SET options were listed in the synopsis was
very confusing.  Move the list to the main description, similar to how
the ALTER TABLE reference page does it.

9 years agodoc: Fix copy-and-paste mistakes
Peter Eisentraut [Tue, 14 Oct 2014 02:10:01 +0000 (22:10 -0400)]
doc: Fix copy-and-paste mistakes

9 years agopsql: Fix \? output alignment
Peter Eisentraut [Tue, 14 Oct 2014 02:07:30 +0000 (22:07 -0400)]
psql: Fix \? output alignment

This was inadvertently changed in commit c64e68fd.

9 years agoFix quoting in the add_to_path Makefile macro.
Noah Misch [Mon, 13 Oct 2014 03:33:37 +0000 (23:33 -0400)]
Fix quoting in the add_to_path Makefile macro.

The previous quoting caused "make -C src/bin check" to ignore, rather
than add to, any LD_LIBRARY_PATH content from the environment.
Back-patch to 9.4, where the macro was introduced.

9 years agoSuppress dead, unportable src/port/crypt.c code.
Noah Misch [Mon, 13 Oct 2014 03:27:06 +0000 (23:27 -0400)]
Suppress dead, unportable src/port/crypt.c code.

This file used __int64, which is specific to native Windows, rather than
int64.  Suppress the long-unused union field of this type.  Noticed on
Cygwin x86_64 with -lcrypt not installed.  Back-patch to 9.0 (all
supported versions).

9 years agopg_recvlogical: Improve --help output
Peter Eisentraut [Sun, 12 Oct 2014 05:45:25 +0000 (01:45 -0400)]
pg_recvlogical: Improve --help output

List the actions first, as they are the most important options.  Group
the other options more sensibly, consistent with the man page.  Correct
a few typographical errors, clarify some things.

Also update the pg_receivexlog --help output to make it a bit more
consistent with that of pg_recvlogical.

9 years agoMessage improvements
Peter Eisentraut [Sun, 12 Oct 2014 05:02:56 +0000 (01:02 -0400)]
Message improvements

9 years agoImprove documentation about JSONB array containment behavior.
Tom Lane [Sat, 11 Oct 2014 18:29:51 +0000 (14:29 -0400)]
Improve documentation about JSONB array containment behavior.

Per gripe from Josh Berkus.

9 years agoFix bogus optimization in JSONB containment tests.
Tom Lane [Sat, 11 Oct 2014 18:13:54 +0000 (14:13 -0400)]
Fix bogus optimization in JSONB containment tests.

When determining whether one JSONB object contains another, it's okay to
make a quick exit if the first object has fewer pairs than the second:
because we de-duplicate keys within objects, it is impossible that the
first object has all the keys the second does.  However, the code was
applying this rule to JSONB arrays as well, where it does *not* hold
because arrays can contain duplicate entries.  The test was really in
the wrong place anyway; we should do it within JsonbDeepContains, where
it can be applied to nested objects not only top-level ones.

Report and test cases by Alexander Korotkov; fix by Peter Geoghegan and
Tom Lane.

9 years agoFix broken example in PL/pgSQL document.
Fujii Masao [Thu, 9 Oct 2014 18:18:01 +0000 (03:18 +0900)]
Fix broken example in PL/pgSQL document.

Back-patch to all supported branches.

Marti Raudsepp, per a report from Marko Tiikkaja

9 years agoFix array overrun in ecpg's version of ParseDateTime().
Tom Lane [Tue, 7 Oct 2014 01:23:20 +0000 (21:23 -0400)]
Fix array overrun in ecpg's version of ParseDateTime().

The code wrote a value into the caller's field[] array before checking
to see if there was room, which of course is backwards.  Per report from
Michael Paquier.

I fixed the equivalent bug in the backend's version of this code way back
in 630684d3a130bb93, but failed to think about ecpg's copy.  Fortunately
this doesn't look like it would be exploitable for anything worse than a
core dump: an external attacker would have no control over the single word
that gets written.

9 years agoStamp 9.4beta3. REL9_4_BETA3
Tom Lane [Mon, 6 Oct 2014 18:32:17 +0000 (14:32 -0400)]
Stamp 9.4beta3.

9 years agoRename pg_recvlogical's --create/--drop to --create-slot/--drop-slot.
Andres Freund [Mon, 6 Oct 2014 10:11:52 +0000 (12:11 +0200)]
Rename pg_recvlogical's --create/--drop to --create-slot/--drop-slot.

A future patch (9.5 only) adds slot management to pg_receivexlog. The
verbs create/drop don't seem descriptive enough there. It seems better
to rename pg_recvlogical's commands now, in beta, than live with the
inconsistency forever.

The old form (e.g. --drop) will still be accepted by virtue of most
getopt_long() options accepting abbreviations for long commands.

Backpatch to 9.4 where pg_recvlogical was introduced.

Author: Michael Paquier and Andres Freund
Discussion: CAB7nPqQtt79U6FmhwvgqJmNyWcVCbbV-nS72j_jyPEopERg9rg@mail.gmail.com

9 years agoTranslation updates
Peter Eisentraut [Mon, 6 Oct 2014 03:22:24 +0000 (23:22 -0400)]
Translation updates

9 years agoUpdate 9.4 release notes for commits through today.
Tom Lane [Sun, 5 Oct 2014 18:14:07 +0000 (14:14 -0400)]
Update 9.4 release notes for commits through today.

Add entries for recent changes, including noting the JSONB format change
and the recent timezone data changes.  We should remove those two items
before 9.4 final: the JSONB change will be of no interest in the long
run, and it's not normally our habit to mention timezone updates in
major-release notes.  But it seems important to document them temporarily
for beta testers.

I failed to resist the temptation to wordsmith a couple of existing
entries, too.

9 years agoEliminate one background-worker-related flag variable.
Robert Haas [Sun, 5 Oct 2014 01:25:41 +0000 (21:25 -0400)]
Eliminate one background-worker-related flag variable.

Teach sigusr1_handler() to use the same test for whether a worker
might need to be started as ServerLoop().  Aside from being perhaps
a bit simpler, this prevents a potentially-unbounded delay when
starting a background worker.  On some platforms, select() doesn't
return when interrupted by a signal, but is instead restarted,
including a reset of the timeout to the originally-requested value.
If signals arrive often enough, but no connection requests arrive,
sigusr1_handler() will be executed repeatedly, but the body of
ServerLoop() won't be reached.  This change ensures that, even in
that case, background workers will eventually get launched.

This is far from a perfect fix; really, we need select() to return
control to ServerLoop() after an interrupt, either via the self-pipe
trick or some other mechanism.  But that's going to require more
work and discussion, so let's do this for now to at least mitigate
the damage.

Per investigation of test_shm_mq failures on buildfarm member anole.

9 years agoUpdate time zone data files to tzdata release 2014h.
Tom Lane [Sat, 4 Oct 2014 18:18:29 +0000 (14:18 -0400)]
Update time zone data files to tzdata release 2014h.

Most zones in the Russian Federation are subtracting one or two hours
as of 2014-10-26.  Update the meanings of the abbreviations IRKT, KRAT,
MAGT, MSK, NOVT, OMST, SAKT, VLAT, YAKT, YEKT to match.

The IANA timezone database has adopted abbreviations of the form AxST/AxDT
for all Australian time zones, reflecting what they believe to be current
majority practice Down Under.  These names do not conflict with usage
elsewhere (other than ACST for Acre Summer Time, which has been in disuse
since 1994).  Accordingly, adopt these names into our "Default" timezone
abbreviation set.  The "Australia" abbreviation set now contains only
CST,EAST,EST,SAST,SAT,WST, all of which are thought to be mostly historical
usage.  Note that SAST has also been changed to be South Africa Standard
Time in the "Default" abbreviation set.

Add zone abbreviations SRET (Asia/Srednekolymsk) and XJT (Asia/Urumqi),
and use WSST/WSDT for western Samoa.

Also a DST law change in the Turks & Caicos Islands (America/Grand_Turk),
and numerous corrections for historical time zone data.

9 years agoUpdate time zone abbreviations lists.
Tom Lane [Fri, 3 Oct 2014 21:44:38 +0000 (17:44 -0400)]
Update time zone abbreviations lists.

This updates known_abbrevs.txt to be what it should have been already,
were my -P patch not broken; and updates some tznames/ entries that
missed getting any love in previous timezone data updates because zic
failed to flag the change of abbreviation.

The non-cosmetic updates:

* Remove references to "ADT" as "Arabia Daylight Time", an abbreviation
that's been out of use since 2007; therefore, claiming there is a conflict
with "Atlantic Daylight Time" doesn't seem especially helpful.  (We have
left obsolete entries in the files when they didn't conflict with anything,
but that seems like a different situation.)

* Fix entirely incorrect GMT offsets for CKT (Cook Islands), FJT, FJST
(Fiji); we didn't even have them on the proper side of the date line.
(Seems to have been aboriginal errors in our tznames data; there's no
evidence anything actually changed recently.)

* FKST (Falkland Islands Summer Time) is now used all year round, so
don't mark it as a DST abbreviation.

* Update SAKT (Sakhalin) to mean GMT+11 not GMT+10.

In cosmetic changes, I fixed a bunch of wrong (or at least obsolete)
claims about abbreviations not being present in the zic files, and
tried to be consistent about how obsolete abbreviations are labeled.

Note the underlying timezone/data files are still at release 2014e;
this is just trying to get us in sync with what those files actually
say before we go to the next update.

9 years agoFix bogus logic for zic -P option.
Tom Lane [Fri, 3 Oct 2014 18:48:11 +0000 (14:48 -0400)]
Fix bogus logic for zic -P option.

The quick hack I added to zic to dump out currently-in-use timezone
abbreviations turns out to have a nasty bug: within each zone, it was
printing the last "struct ttinfo" to be *defined*, not necessarily the
last one in use.  This was mainly a problem in zones that had changed the
meaning of their zone abbreviation (to another GMT offset value) and later
changed it back.

As a result of this error, we'd missed out updating the tznames/ files
for some jurisdictions that have changed their zone abbreviations since
the tznames/ files were originally created.  I'll address the missing data
updates in a separate commit.

9 years agoDon't balance vacuum cost delay when per-table settings are in effect
Alvaro Herrera [Fri, 3 Oct 2014 16:01:27 +0000 (13:01 -0300)]
Don't balance vacuum cost delay when per-table settings are in effect

When there are cost-delay-related storage options set for a table,
trying to make that table participate in the autovacuum cost-limit
balancing algorithm produces undesirable results: instead of using the
configured values, the global values are always used,
as illustrated by Mark Kirkwood in
http://www.postgresql.org/message-id/52FACF15.8020507@catalyst.net.nz

Since the mechanism is already complicated, just disable it for those
cases rather than trying to make it cope.  There are undesirable
side-effects from this too, namely that the total I/O impact on the
system will be higher whenever such tables are vacuumed.  However, this
is seen as less harmful than slowing down vacuum, because that would
cause bloat to accumulate.  Anyway, in the new system it is possible to
tweak options to get the precise behavior one wants, whereas with the
previous system one was simply hosed.

This has been broken forever, so backpatch to all supported branches.
This might affect systems where cost_limit and cost_delay have been set
for individual tables.

9 years agoCheck for GiST index tuples that don't fit on a page.
Heikki Linnakangas [Fri, 3 Oct 2014 09:07:10 +0000 (12:07 +0300)]
Check for GiST index tuples that don't fit on a page.

The page splitting code would go into infinite recursion if you try to
insert an index tuple that doesn't fit even on an empty page.

Per analysis and suggested fix by Andrew Gierth. Fixes bug #11555, reported
by Bryan Seitz (analysis happened over IRC). Backpatch to all supported
versions.

9 years agoFix typo in error message.
Heikki Linnakangas [Thu, 2 Oct 2014 12:51:31 +0000 (15:51 +0300)]
Fix typo in error message.

9 years agoFix some more problems with nested append relations.
Tom Lane [Wed, 1 Oct 2014 23:30:27 +0000 (19:30 -0400)]
Fix some more problems with nested append relations.

As of commit a87c72915 (which later got backpatched as far as 9.1),
we're explicitly supporting the notion that append relations can be
nested; this can occur when UNION ALL constructs are nested, or when
a UNION ALL contains a table with inheritance children.

Bug #11457 from Nelson Page, as well as an earlier report from Elvis
Pranskevichus, showed that there were still nasty bugs associated with such
cases: in particular the EquivalenceClass mechanism could try to generate
"join" clauses connecting an appendrel child to some grandparent appendrel,
which would result in assertion failures or bogus plans.

Upon investigation I concluded that all current callers of
find_childrel_appendrelinfo() need to be fixed to explicitly consider
multiple levels of parent appendrels.  The most complex fix was in
processing of "broken" EquivalenceClasses, which are ECs for which we have
been unable to generate all the derived equality clauses we would like to
because of missing cross-type equality operators in the underlying btree
operator family.  That code path is more or less entirely untested by
the regression tests to date, because no standard opfamilies have such
holes in them.  So I wrote a new regression test script to try to exercise
it a bit, which turned out to be quite a worthwhile activity as it exposed
existing bugs in all supported branches.

The present patch is essentially the same as far back as 9.2, which is
where parameterized paths were introduced.  In 9.0 and 9.1, we only need
to back-patch a small fragment of commit 5b7b5518d, which fixes failure to
propagate out the original WHERE clauses when a broken EC contains constant
members.  (The regression test case results show that these older branches
are noticeably stupider than 9.2+ in terms of the quality of the plans
generated; but we don't really care about plan quality in such cases,
only that the plan not be outright wrong.  A more invasive fix in the
older branches would not be a good idea anyway from a plan-stability
standpoint.)

9 years agoFix damange from wrongly split commit in fdf81c9a6cf94.
Andres Freund [Wed, 1 Oct 2014 17:24:50 +0000 (19:24 +0200)]
Fix damange from wrongly split commit in fdf81c9a6cf94.

Unfortunately I mistakenly split the commit wrongly into two parts,
leaving one part of renaming StreamLog to StreamLogicalLog in the
second commit. Which isn't backported to 9.4...
Fix it in 9.4 only, as master already is 'fixed' by the subsequent
commit.

Noticed by Jan Wieck and the buildfarm.

9 years agopg_recvlogical.c code review.
Andres Freund [Mon, 29 Sep 2014 13:35:40 +0000 (15:35 +0200)]
pg_recvlogical.c code review.

Several comments still referred to 'initiating', 'freeing', 'stopping'
replication slots. These were terms used during different phases of
the development of logical decoding, but are no long accurate.

Also rename StreamLog() to StreamLogicalLog() and add 'void' to the
prototype.

Author: Michael Paquier, with some editing by me.

Backpatch to 9.4 where pg_recvlogical was introduced.

9 years agoRemove num_xloginsert_locks GUC, replace with a #define
Heikki Linnakangas [Wed, 1 Oct 2014 13:37:15 +0000 (16:37 +0300)]
Remove num_xloginsert_locks GUC, replace with a #define

I left the GUC in place for the beta period, so that people could experiment
with different values. No-one's come up with any data that a different value
would be better under some circumstances, so rather than try to document to
users what the GUC, let's just hard-code the current value, 8.

9 years agoBlock signals while computing the sleep time in postmaster's main loop.
Andres Freund [Wed, 1 Oct 2014 12:23:43 +0000 (14:23 +0200)]
Block signals while computing the sleep time in postmaster's main loop.

DetermineSleepTime() was previously called without blocked
signals. That's not good, because it allows signal handlers to
interrupt its workings.

DetermineSleepTime() was added in 9.3 with the addition of background
workers (da07a1e856511), where it only read from
BackgroundWorkerList.

Since 9.4, where dynamic background workers were added (7f7485a0cde),
the list is also manipulated in DetermineSleepTime(). That's bad
because the list now can be persistently corrupted if modified by both
a signal handler and DetermineSleepTime().

This was discovered during the investigation of hangs on buildfarm
member anole. It's unclear whether this bug is the source of these
hangs or not, but it's worth fixing either way. I have confirmed that
it can cause crashes.

It luckily looks like this only can cause problems when bgworkers are
actively used.

Discussion: 20140929193733.GB14400@awork2.anarazel.de

Backpatch to 9.3 where background workers were introduced.

9 years agoImprove documentation about binary/textual output mode for output plugins.
Andres Freund [Wed, 1 Oct 2014 11:13:59 +0000 (13:13 +0200)]
Improve documentation about binary/textual output mode for output plugins.

Discussion: CAB7nPqQrqFzjqCjxu4GZzTrD9kpj6HMn9G5aOOMwt1WZ8NfqeA@mail.gmail.com,
    CAB7nPqQXc_+g95zWnqaa=mVQ4d3BVRs6T41frcEYi2ocUrR3+A@mail.gmail.com

Per discussion between Michael Paquier, Robert Haas and Andres Freund

Backpatch to 9.4 where logical decoding was introduced.

9 years agoRename CACHE_LINE_SIZE to PG_CACHE_LINE_SIZE.
Andres Freund [Wed, 1 Oct 2014 09:54:05 +0000 (11:54 +0200)]
Rename CACHE_LINE_SIZE to PG_CACHE_LINE_SIZE.

As noted in http://bugs.debian.org/763098 there is a conflict between
postgres' definition of CACHE_LINE_SIZE and the definition by various
*bsd platforms. It's debatable who has the right to define such a
name, but postgres' use was only introduced in 375d8526f290 (9.4), so
it seems like a good idea to rename it.

Discussion: 20140930195756.GC27407@msg.df7cb.de

Per complaint of Christoph Berg in the above email, although he's not
the original bug reporter.

Backpatch to 9.4 where the define was introduced.

9 years agoCorrect stdin/stdout usage in COPY .. PROGRAM
Stephen Frost [Tue, 30 Sep 2014 19:55:28 +0000 (15:55 -0400)]
Correct stdin/stdout usage in COPY .. PROGRAM

The COPY documentation incorrectly stated, for the PROGRAM case,
that we read from stdin and wrote to stdout.  Fix that, and improve
consistency by referring to the 'PostgreSQL' user instead of the
'postgres' user, as is done in the rest of the COPY documentation.

Pointed out by Peter van Dijk.

Back-patch to 9.3 where COPY .. PROGRAM was introduced.

9 years agoFix pg_dump's --if-exists for large objects
Alvaro Herrera [Tue, 30 Sep 2014 15:06:37 +0000 (12:06 -0300)]
Fix pg_dump's --if-exists for large objects

This was born broken in 9067310cc5dd590e36c2c3219dbf3961d7c9f8cb.

Per trouble report from Joachim Wieland.

Pavel Stěhule and Álvaro Herrera

9 years agopg_upgrade: have pg_upgrade fail for old 9.4 JSONB format
Bruce Momjian [Tue, 30 Sep 2014 00:19:59 +0000 (20:19 -0400)]
pg_upgrade:  have pg_upgrade fail for old 9.4 JSONB format

Backpatch through 9.4

9 years agoChange JSONB's on-disk format for improved performance.
Tom Lane [Mon, 29 Sep 2014 16:29:24 +0000 (12:29 -0400)]
Change JSONB's on-disk format for improved performance.

The original design used an array of offsets into the variable-length
portion of a JSONB container.  However, such an array is basically
uncompressible by simple compression techniques such as TOAST's LZ
compressor.  That's bad enough, but because the offset array is at the
front, it tended to trigger the give-up-after-1KB heuristic in the TOAST
code, so that the entire JSONB object was stored uncompressed; which was
the root cause of bug #11109 from Larry White.

To fix without losing the ability to extract a random array element in O(1)
time, change this scheme so that most of the JEntry array elements hold
lengths rather than offsets.  With data that's compressible at all, there
tend to be fewer distinct element lengths, so that there is scope for
compression of the JEntry array.  Every N'th entry is still an offset.
To determine the length or offset of any specific element, we might have
to examine up to N preceding JEntrys, but that's still O(1) so far as the
total container size is concerned.  Testing shows that this cost is
negligible compared to other costs of accessing a JSONB field, and that
the method does largely fix the incompressible-data problem.

While at it, rearrange the order of elements in a JSONB object so that
it's "all the keys, then all the values" not alternating keys and values.
This doesn't really make much difference right at the moment, but it will
allow providing a fast path for extracting individual object fields from
large JSONB values stored EXTERNAL (ie, uncompressed), analogously to the
existing optimization for substring extraction from large EXTERNAL text
values.

Bump catversion to denote the incompatibility in on-disk format.
We will need to fix pg_upgrade to disallow upgrading jsonb data stored
with 9.4 betas 1 and 2.

Heikki Linnakangas and Tom Lane

9 years agoFix identify_locking_dependencies for schema-only dumps.
Robert Haas [Fri, 26 Sep 2014 15:21:35 +0000 (11:21 -0400)]
Fix identify_locking_dependencies for schema-only dumps.

Without this fix, parallel restore of a schema-only dump can deadlock,
because when the dump is schema-only, the dependency will still be
pointing at the TABLE item rather than the TABLE DATA item.

Robert Haas and Tom Lane

9 years agoRemove ill-conceived ban on zero length json object keys.
Andrew Dunstan [Thu, 25 Sep 2014 19:08:42 +0000 (15:08 -0400)]
Remove ill-conceived ban on zero length json object keys.

We removed a similar ban on this in json_object recently, but the ban in
datum_to_json was left, which generate4d sprutious errors in othee json
generators, notable json_build_object.

Along the way, add an assertion that datum_to_json is not passed a null
key. All current callers comply with this rule, but the assertion will
catch any possible future misbehaviour.

9 years agoFix VPATH builds of the replication parser from git for some !gcc compilers.
Andres Freund [Thu, 25 Sep 2014 13:22:26 +0000 (15:22 +0200)]
Fix VPATH builds of the replication parser from git for some !gcc compilers.

Some compilers don't automatically search the current directory for
included files. 9cc2c182fc2 fixed that for builds from tarballs by
adding an include to the source directory. But that doesn't work when
the scanner is generated in the VPATH directory. Use the same search
path as the other parsers in the tree.

One compiler that definitely was affected is solaris' sun cc.

Backpatch to 9.1 which introduced using an actual parser for
replication commands.

9 years agoReturn NULL from json_object_agg if it gets no rows.
Andrew Dunstan [Thu, 25 Sep 2014 12:18:18 +0000 (08:18 -0400)]
Return NULL from json_object_agg if it gets no rows.

This makes it consistent with the docs and with all other builtin
aggregates apart from count().

9 years agoFix bogus variable-mangling in security_barrier_replace_vars().
Tom Lane [Wed, 24 Sep 2014 19:59:37 +0000 (15:59 -0400)]
Fix bogus variable-mangling in security_barrier_replace_vars().

This function created new Vars with varno different from varnoold, which
is a condition that should never prevail before setrefs.c does the final
variable-renumbering pass.  The created Vars could not be seen as equal()
to normal Vars, which among other things broke equivalence-class processing
for them.  The consequences of this were indeed visible in the regression
tests, in the form of failure to propagate constants as one would expect.
I stumbled across it while poking at bug #11457 --- after intentionally
disabling join equivalence processing, the security-barrier regression
tests started falling over with fun errors like "could not find pathkey
item to sort", because of failure to match the corrupted Vars to normal
ones.

9 years agoFix typos in descriptions of json_object functions.
Andrew Dunstan [Wed, 24 Sep 2014 15:24:42 +0000 (11:24 -0400)]
Fix typos in descriptions of json_object functions.

9 years agoFix incorrect search for "x?" style matches in creviterdissect().
Tom Lane [Wed, 24 Sep 2014 00:25:33 +0000 (20:25 -0400)]
Fix incorrect search for "x?" style matches in creviterdissect().

When the number of allowed iterations is limited (either a "?" quantifier
or a bound expression), the last sub-match has to reach to the end of the
target string.  The previous coding here first tried the shortest possible
match (one character, usually) and then gave up and back-tracked if that
didn't work, typically leading to failure to match overall, as shown in
bug #11478 from Christoph Berg.  The minimum change to fix that would be to
not decrement k before "goto backtrack"; but that would be a pretty stupid
solution, because we'd laboriously try each possible sub-match length
before finally discovering that only ending at the end can work.  Instead,
force the sub-match endpoint limit up to the end for even the first
shortest() call if we cannot have any more sub-matches after this one.

Bug introduced in my rewrite that added the iterdissect logic, commit
173e29aa5deefd9e71c183583ba37805c8102a72.  The shortest-first search code
was too closely modeled on the longest-first code, which hasn't got this
issue since it tries a match reaching to the end to start with anyway.
Back-patch to all affected branches.

9 years agoLog ALTER SYSTEM statements as DDL
Stephen Frost [Tue, 23 Sep 2014 00:50:17 +0000 (20:50 -0400)]
Log ALTER SYSTEM statements as DDL

Per discussion in bug #11350, log ALTER SYSTEM commands at the
log_statement=ddl level, rather than at the log_statement=all level.

Pointed out by Tomonari Katsumata.

Back-patch to 9.4 where ALTER SYSTEM was introduced.

9 years agoProcess withCheckOption exprs in setrefs.c
Stephen Frost [Tue, 23 Sep 2014 00:22:16 +0000 (20:22 -0400)]
Process withCheckOption exprs in setrefs.c

While withCheckOption exprs had been handled in many cases by
happenstance, they need to be handled during set_plan_references and
more specifically down in set_plan_refs for ModifyTable plan nodes.
This is to ensure that the opfuncid's are set for operators referenced
in the withCheckOption exprs.

Identified as an issue by Thom Brown

Patch by Dean Rasheed

Back-patch to 9.4, where withCheckOption was introduced.

9 years agoFix mishandling of CreateEventTrigStmt's eventname field.
Robert Haas [Mon, 22 Sep 2014 20:05:51 +0000 (16:05 -0400)]
Fix mishandling of CreateEventTrigStmt's eventname field.

It's a string, not a scalar.

Petr Jelinek

9 years agoFix failure of contrib/auto_explain to print per-node timing information.
Tom Lane [Fri, 19 Sep 2014 17:18:59 +0000 (13:18 -0400)]
Fix failure of contrib/auto_explain to print per-node timing information.

This has been broken since commit af7914c6627bcf0b0ca614e9ce95d3f8056602bf,
which added the EXPLAIN (TIMING) option.  Although that commit included
updates to auto_explain, they evidently weren't tested very carefully,
because the code failed to print node timings even when it should, due to
failure to set es.timing in the ExplainState struct.  Reported off-list by
Neelakanth Nadgir of Salesforce.

In passing, clean up the documentation for auto_explain's options a
little bit, including re-ordering them into what seems to me a more
logical order.

9 years agoMark x86's memory barrier inline assembly as clobbering the cpu flags.
Andres Freund [Fri, 19 Sep 2014 15:04:00 +0000 (17:04 +0200)]
Mark x86's memory barrier inline assembly as clobbering the cpu flags.

x86's memory barrier assembly was marked as clobbering "memory" but
not "cc" even though 'addl' sets various flags. As it turns out gcc on
x86 implicitly assumes "cc" on every inline assembler statement, so
it's not a bug. But as that's poorly documented and might get copied
to architectures or compilers where that's not the case, it seems
better to be precise.

Discussion: 20140919100016.GH4277@alap3.anarazel.de

To keep the code common, backpatch to 9.2 where explicit memory
barriers were introduced.

10 years agoFix TAP checks when current directory name contains spaces
Peter Eisentraut [Wed, 17 Sep 2014 04:54:12 +0000 (00:54 -0400)]
Fix TAP checks when current directory name contains spaces

Add some quotes in the makefile snippet that creates the temporary
installation, so that it can handle spaces in the directory name and
possibly some other oddities.

10 years agoFix the return type of GIN triConsistent support functions to "char".
Heikki Linnakangas [Tue, 16 Sep 2014 06:11:49 +0000 (09:11 +0300)]
Fix the return type of GIN triConsistent support functions to "char".

They were marked to return a boolean, but they actually return a
GinTernaryValue, which is more like a "char". It makes no practical
difference, as the triConsistent functions cannot be called directly from
SQL because they have "internal" arguments, but this nevertheless seems
more correct.

Also fix the GinTernaryValue name in the documentation. I renamed the enum
earlier, but neglected the docs.

Alexander Korotkov. This is new in 9.4, so backpatch there.

10 years agoHandle border = 3 in expanded mode
Stephen Frost [Fri, 12 Sep 2014 15:24:09 +0000 (11:24 -0400)]
Handle border = 3 in expanded mode

In psql, expanded mode was not being displayed correctly when using
the normal ascii or unicode linestyles and border set to '3'.  Now,
per the documentation, border '3' is really only sensible for HTML
and LaTeX formats, however, that's no excuse for ascii/unicode to
break in that case, and provisions had been made for psql to cleanly
handle this case (and it did, in non-expanded mode).

This was broken when ascii/unicode was initially added a good five
years ago because print_aligned_vertical_line wasn't passed in the
border setting being used by print_aligned_vertical but instead was
given the whole printTableContent.  There really isn't a good reason
for vertical_line to have the entire printTableContent structure, so
just pass in the printTextFormat and border setting (similar to how
this is handled in horizontal_line).

Pointed out by Pavel Stehule, fix by me.

Back-patch to all currently-supported versions.

10 years agoSupport ALTER SYSTEM RESET command.
Fujii Masao [Tue, 2 Sep 2014 07:06:58 +0000 (16:06 +0900)]
Support ALTER SYSTEM RESET command.

This patch allows us to execute ALTER SYSTEM RESET command to
remove the configuration entry from postgresql.auto.conf.

Vik Fearing, reviewed by Amit Kapila and me.

10 years agoFix GIN data page split ratio calculation.
Heikki Linnakangas [Fri, 12 Sep 2014 08:23:59 +0000 (11:23 +0300)]
Fix GIN data page split ratio calculation.

The code that tried to split a page at 75/25 ratio, when appending to the
end of an index, was buggy in two ways. First, there was a silly typo that
caused it to just fill the left page as full as possible. But the logic as
it was intended wasn't correct either, and would actually have given a ratio
closer to 60/40 than 75/25.

Gaetano Mendola spotted the typo. Backpatch to 9.4, where this code was added.

10 years agoFix power_var_int() for large integer exponents.
Tom Lane [Fri, 12 Sep 2014 03:30:54 +0000 (23:30 -0400)]
Fix power_var_int() for large integer exponents.

The code for raising a NUMERIC value to an integer power wasn't very
careful about large powers.  It got an outright wrong answer for an
exponent of INT_MIN, due to failure to consider overflow of the Abs(exp)
operation; which is fixable by using an unsigned rather than signed
exponent value after that point.  Also, even though the number of
iterations of the power-computation loop is pretty limited, it's easy for
the repeated squarings to result in ridiculously enormous intermediate
values, which can take unreasonable amounts of time/memory to process,
or even overflow the internal "weight" field and so produce a wrong answer.
We can forestall misbehaviors of that sort by bailing out as soon as the
weight value exceeds what will fit in int16, since then the final answer
must overflow (if exp > 0) or underflow (if exp < 0) the packed numeric
format.

Per off-list report from Pavel Stehule.  Back-patch to all supported
branches.

10 years agoFix vacuumdb --analyze-in-stages --all order
Peter Eisentraut [Fri, 12 Sep 2014 01:08:59 +0000 (21:08 -0400)]
Fix vacuumdb --analyze-in-stages --all order

When running vacuumdb --analyze-in-stages --all, it needs to run the
first stage across all databases before the second one, instead of
running all stages in a database before processing the next one.

Also respect the --quiet option with --analyze-in-stages.

10 years agopg_upgrade: preserve the timestamp epoch
Bruce Momjian [Thu, 11 Sep 2014 22:39:46 +0000 (18:39 -0400)]
pg_upgrade:  preserve the timestamp epoch

This is useful for replication tools like Slony and Skytools.  This is a
backpatch of a74a4aa23bb95b590ff01ee564219d2eacea3706.

Report by Sergey Konoplev

Backpatch through 9.3

10 years agoRemove dead InRecovery check.
Heikki Linnakangas [Thu, 11 Sep 2014 19:43:56 +0000 (22:43 +0300)]
Remove dead InRecovery check.

With the new B-tree incomplete split handling in 9.4, _bt_insert_parent is
never called in recovery.

10 years agoFix Windows build.
Heikki Linnakangas [Thu, 11 Sep 2014 12:15:40 +0000 (15:15 +0300)]
Fix Windows build.

I renamed a variable, but missed an #ifdef WIN32 block.

10 years agoSimplify calculation of Poisson distributed delays in pgbench --rate mode.
Heikki Linnakangas [Thu, 11 Sep 2014 10:00:48 +0000 (13:00 +0300)]
Simplify calculation of Poisson distributed delays in pgbench --rate mode.

The previous coding first generated a uniform random value between 0.0 and
1.0, then converted that to an integer between 1 and 10000, and divided that
again by 10000. Those conversions are unnecessary; we can use the double
value that pg_erand48() returns directly. While we're at it, put the logic
into a helper function, getPoissonRand().

The largest delay generated by the old coding was about 9.2 times the
average, because of the way the uniformly distributed value used for the
calculation was truncated to 1/10000 granularity. The new coding doesn't
have such clamping. With my laptop's DBL_MIN value, the maximum delay with
the new coding is about 700x the average. That seems acceptable - any
reasonable pgbench session should last long enough to average that out.

Backpatch to 9.4.

10 years agoChange the way latency is calculated with pgbench --rate option.
Heikki Linnakangas [Thu, 11 Sep 2014 09:40:01 +0000 (12:40 +0300)]
Change the way latency is calculated with pgbench --rate option.

The reported latency values now include the "schedule lag" time, that is,
the time between the transaction's scheduled start time and the time it
actually started. This relates better to a model where requests arrive at a
certain rate, and we are interested in the response time to the end user or
application, rather than the response time of the database itself.

Also, when --rate is used, include the schedule lag time in the log output.

The --rate option is new in 9.4, so backpatch to 9.4. It seems better to
make this change in 9.4, while we're still in the beta period, than ship a
9.4 version that calculates the values differently than 9.5.

10 years agoHandle old versions of Test::More
Peter Eisentraut [Thu, 11 Sep 2014 00:39:28 +0000 (20:39 -0400)]
Handle old versions of Test::More

Really old versions of Test::More don't support subplans, so skip the
tests in that case.

10 years agoSupport older versions of "prove"
Peter Eisentraut [Thu, 11 Sep 2014 00:05:56 +0000 (20:05 -0400)]
Support older versions of "prove"

Apparently, older versions of "prove" (couldn't identify the exact
version from the changelog) don't look into the t/ directory for tests
by default, so specify it explicitly.

10 years agodoc: improve configuration management section
Bruce Momjian [Thu, 11 Sep 2014 00:50:15 +0000 (20:50 -0400)]
doc:  improve configuration management section

Patch by David Johnston

Backpatch through 9.4

10 years agoPreserve AND/OR flatness while extracting restriction OR clauses.
Tom Lane [Tue, 9 Sep 2014 22:35:17 +0000 (18:35 -0400)]
Preserve AND/OR flatness while extracting restriction OR clauses.

The code I added in commit f343a880d5555faf1dad0286c5632047c8f599ad was
careless about preserving AND/OR flatness: it could create a structure with
an OR node directly underneath another one.  That breaks an assumption
that's fairly important for planning efficiency, not to mention triggering
various Asserts (as reported by Benjamin Smith).  Add a trifle more logic
to handle the case properly.

10 years agoFix typo in solaris spinlock fix.
Andres Freund [Tue, 9 Sep 2014 11:57:38 +0000 (13:57 +0200)]
Fix typo in solaris spinlock fix.

07968dbfaad03 missed part of the S_UNLOCK define when building for
sparcv8+.

10 years agoFix spinlock implementation for some !solaris sparc platforms.
Andres Freund [Mon, 8 Sep 2014 22:47:32 +0000 (00:47 +0200)]
Fix spinlock implementation for some !solaris sparc platforms.

Some Sparc CPUs can be run in various coherence models, ranging from
RMO (relaxed) over PSO (partial) to TSO (total). Solaris has always
run CPUs in TSO mode while in userland, but linux didn't use to and
the various *BSDs still don't. Unfortunately the sparc TAS/S_UNLOCK
were only correct under TSO. Fix that by adding the necessary memory
barrier instructions. On sparcv8+, which should be all relevant CPUs,
these are treated as NOPs if the current consistency model doesn't
require the barriers.

Discussion: 20140630222854.GW26930@awork2.anarazel.de

Will be backpatched to all released branches once a few buildfarm
cycles haven't shown up problems. As I've no access to sparc, this is
blindly written.

10 years agodoc: Reflect renaming of Mac OS X to OS X
Peter Eisentraut [Tue, 9 Sep 2014 17:56:29 +0000 (13:56 -0400)]
doc: Reflect renaming of Mac OS X to OS X

bug #10528

10 years agoMove ALTER ... ALL IN to ProcessUtilitySlow
Stephen Frost [Tue, 9 Sep 2014 14:52:10 +0000 (10:52 -0400)]
Move ALTER ... ALL IN to ProcessUtilitySlow

Now that ALTER TABLE .. ALL IN TABLESPACE has replaced the previous
ALTER TABLESPACE approach, it makes sense to move the calls down in
to ProcessUtilitySlow where the rest of ALTER TABLE is handled.

This also means that event triggers will support ALTER TABLE .. ALL
(which was the impetus for the original change, though it has other
good qualities also).

Álvaro Herrera

Back-patch to 9.4 as the original rework was.

10 years agoFix psql \s to work with recent libedit, and add pager support.
Tom Lane [Mon, 8 Sep 2014 20:09:49 +0000 (16:09 -0400)]
Fix psql \s to work with recent libedit, and add pager support.

psql's \s (print command history) doesn't work at all with recent libedit
versions when printing to the terminal, because libedit tries to do an
fchmod() on the target file which will fail if the target is /dev/tty.
(We'd already noted this in the context of the target being /dev/null.)
Even before that, it didn't work pleasantly, because libedit likes to
encode the command history file (to ensure successful reloading), which
renders it nigh unreadable, not to mention significantly different-looking
depending on exactly which libedit version you have.  So let's forget using
write_history() for this purpose, and instead print the data ourselves,
using logic similar to that used to iterate over the history for newline
encoding/decoding purposes.

While we're at it, insert the ability to use the pager when \s is printing
to the terminal.  This has been an acknowledged shortcoming of \s for many
years, so while you could argue it's not exactly a back-patchable bug fix
it still seems like a good improvement.  Anyone who's seriously annoyed
at this can use "\s /dev/tty" or local equivalent to get the old behavior.

Experimentation with this showed that the history iteration logic was
actually rather broken when used with libedit.  It turns out that with
libedit you have to use previous_history() not next_history() to advance
to more recent history entries.  The easiest and most robust fix for this
seems to be to make a run-time test to verify which function to call.
We had not noticed this because libedit doesn't really need the newline
encoding logic: its own encoding ensures that command entries containing
newlines are reloaded correctly (unlike libreadline).  So the effective
behavior with recent libedits was that only the oldest history entry got
newline-encoded or newline-decoded.  However, because of yet other bugs in
history_set_pos(), some old versions of libedit allowed the existing loop
logic to reach entries besides the oldest, which means there may be libedit
~/.psql_history files out there containing encoded newlines in more than
just the oldest entry.  To ensure we can reload such files, it seems
appropriate to back-patch this fix, even though that will result in some
incompatibility with older psql versions (ie, multiline history entries
written by a psql with this fix will look corrupted to a psql without it,
if its libedit is reasonably up to date).

Stepan Rutz and Tom Lane

10 years agoDocumentation fix: sum(float4) returns float4, not float8.
Tom Lane [Mon, 8 Sep 2014 02:40:41 +0000 (22:40 -0400)]
Documentation fix: sum(float4) returns float4, not float8.

The old claim is from my commit d06ebdb8d3425185d7e641d15e45908658a0177d of
2000-07-17, but it seems to have been a plain old thinko; sum(float4) has
been distinct from sum(float8) since Berkeley days.  Noted by KaiGai Kohei.

While at it, mention the existence of sum(money), which is also of
embarrassingly ancient vintage.

10 years agoTab completion for ALTER .. ALL IN TABLESPACE
Stephen Frost [Sun, 7 Sep 2014 12:04:35 +0000 (08:04 -0400)]
Tab completion for ALTER .. ALL IN TABLESPACE

Update the tab completion for the changes made in
3c4cf080879b386d4ed1814667aca025caafe608, which rework 'MOVE ALL' to be
'ALTER .. ALL IN TABLESPACE'.

Fujii Masao

Back-patch to 9.4, as the original change was.

10 years agodocs: Improve pg_isready details about username/dbname
Bruce Momjian [Sat, 6 Sep 2014 16:43:11 +0000 (12:43 -0400)]
docs:  Improve pg_isready details about username/dbname

Report by Erik Rijkers

Backpatch through 9.4

10 years agoProperly document that -r is only honored from the command-line.
Bruce Momjian [Sat, 6 Sep 2014 15:10:51 +0000 (11:10 -0400)]
Properly document that -r is only honored from the command-line.

This is for postgres/postmaster options.

Report by Tom Lane

Backpatch through 9.4

10 years agoClarify documentation about "peer" rows in window functions
Bruce Momjian [Fri, 5 Sep 2014 23:01:26 +0000 (19:01 -0400)]
Clarify documentation about "peer" rows in window functions

Peer rows are matching rows when ORDER BY is specified.

Report by arnaud.mouronval@gmail.com, David G Johnston

Backpatch through 9.4

10 years agoAssorted message fixes and improvements
Peter Eisentraut [Fri, 5 Sep 2014 05:20:33 +0000 (01:20 -0400)]
Assorted message fixes and improvements

10 years agoAdd tab-completion for reloptions like user_catalog_table.
Fujii Masao [Fri, 5 Sep 2014 02:40:08 +0000 (11:40 +0900)]
Add tab-completion for reloptions like user_catalog_table.

Back-patch to 9.4 where user_catalog_table was added.

Review by Michael Paquier

10 years agodoc: Remove dead link
Peter Eisentraut [Thu, 4 Sep 2014 18:11:23 +0000 (14:11 -0400)]
doc: Remove dead link

The link to the NIST web page about DES standards leads to nowhere, and
according to archive.org has been forwarded to an unrelated page for
many years.  Therefore, just remove that link.  More up to date
information can be found via Wikipedia, for example.

10 years agoFix segmentation fault that an empty prepared statement could cause.
Fujii Masao [Thu, 4 Sep 2014 17:17:57 +0000 (02:17 +0900)]
Fix segmentation fault that an empty prepared statement could cause.

Back-patch to all supported branches.

Per bug #11335 from Haruka Takatsuka

10 years agodocs: Improve documentation of \pset without arguments.
Fujii Masao [Thu, 4 Sep 2014 04:48:09 +0000 (13:48 +0900)]
docs: Improve documentation of \pset without arguments.

The syntax summary previously failed to clarify that the first
argument is also optional.  The textual description did mention it,
but all the way at the bottom.  It fits better with the command
overview, so move it there, and fix the summary also.

Back-patch to 9.4 where \pset without arguments was supported.

Dilip Kumar, reviewed by Fabien Coelho

10 years agoUpdate URL reference material in /contrib/isn docs
Bruce Momjian [Wed, 3 Sep 2014 21:22:20 +0000 (17:22 -0400)]
Update URL reference material in /contrib/isn docs

Report by Peter Eisentraut

10 years agoDocument use of partial indexes for partial unique constraints
Bruce Momjian [Wed, 3 Sep 2014 18:34:46 +0000 (14:34 -0400)]
Document use of partial indexes for partial unique constraints

Report by Tomáš Greif

Backpatch through 9.4

10 years agoSilence warning on new versions of clang.
Heikki Linnakangas [Tue, 2 Sep 2014 11:22:42 +0000 (14:22 +0300)]
Silence warning on new versions of clang.

Andres Freund

10 years agoAdd skip-empty-xacts option to test_decoding for use in the regression tests.
Andres Freund [Mon, 1 Sep 2014 11:42:43 +0000 (13:42 +0200)]
Add skip-empty-xacts option to test_decoding for use in the regression tests.

The regression tests for contrib/test_decoding regularly failed on
postgres instances that were very slow. Either because the hardware
itself was slow or because very expensive debugging options like
CLOBBER_CACHE_ALWAYS were used.

The reason they failed was just that some additional transactions were
decoded. Analyze and vacuum, triggered by autovac.

To fix just add a option to test_decoding to only display transactions
in which a change was actually displayed. That's not pretty because it
removes information from the tests; but better than constantly failing
tests in very likely harmless ways.

Backpatch to 9.4 where logical decoding was introduced.

Discussion: 20140629142511.GA26930@awork2.anarazel.de

10 years agoDeclare lwlock.c's LWLockAcquireCommon() as a static inline.
Andres Freund [Sun, 31 Aug 2014 22:17:18 +0000 (00:17 +0200)]
Declare lwlock.c's LWLockAcquireCommon() as a static inline.

68a2e52bbaf98f136 has introduced LWLockAcquireCommon() containing the
previous contents of LWLockAcquire() plus added functionality. The
latter then calls it, just like LWLockAcquireWithVar(). Because the
majority of callers don't need the added functionality, declare the
common code as inline. The compiler then can optimize away the unused
code. Doing so is also useful when looking at profiles, to
differentiate the users.

Backpatch to 9.4, the first branch to contain LWLockAcquireCommon().

10 years agodoc: Various typo/grammar fixes
Kevin Grittner [Sat, 30 Aug 2014 16:01:47 +0000 (11:01 -0500)]
doc: Various typo/grammar fixes

Errors detected using Topy (https://github.com/intgr/topy), all
changes verified by hand and some manual tweaks added.

Marti Raudsepp

Individual changes backpatched, where applicable, as far as 9.0.

10 years agopg_is_xlog_replay_paused(): remove super-user-only restriction
Bruce Momjian [Fri, 29 Aug 2014 13:05:35 +0000 (09:05 -0400)]
pg_is_xlog_replay_paused():  remove super-user-only restriction

Also update docs to mention which function are super-user-only.

Report by sys-milan@statpro.com

Backpatch through 9.4

10 years agoFix bug in compressed GIN data leaf page splitting code.
Heikki Linnakangas [Fri, 29 Aug 2014 11:19:34 +0000 (14:19 +0300)]
Fix bug in compressed GIN data leaf page splitting code.

The list of posting lists it's dealing with can contain placeholders for
deleted posting lists. The placeholders are kept around so that they can
be WAL-logged, but we must be careful to not try to access them.

This fixes bug #11280, reported by Mårten Svantesson. Backpatch to 9.4,
where the compressed data leaf page code was added.

10 years agoAssorted message improvements
Peter Eisentraut [Fri, 29 Aug 2014 04:01:34 +0000 (00:01 -0400)]
Assorted message improvements

10 years agodoc: Revert ALTER TABLESPACE summary line
Peter Eisentraut [Fri, 29 Aug 2014 03:59:03 +0000 (23:59 -0400)]
doc: Revert ALTER TABLESPACE summary line

It was changed when ALTER TABLESPACE / MOVE was added but then not
updated when that was moved back out.

10 years agoFix citext upgrade script for disallowance of oidvector element assignment.
Tom Lane [Thu, 28 Aug 2014 22:21:11 +0000 (18:21 -0400)]
Fix citext upgrade script for disallowance of oidvector element assignment.

In commit 45e02e3232ac7cc5ffe36f7986159b5e0b1f6fdc, we intentionally
disallowed updates on individual elements of oidvector columns.  While that
still seems like a sane idea in the abstract, we (I) forgot that citext's
"upgrade from unpackaged" script did in fact perform exactly such updates,
in order to fix the problem that citext indexes should have a collation
but would not in databases dumped or upgraded from pre-9.1 installations.

Even if we wanted to add casts to allow such updates, there's no practical
way to do so in the back branches, so the only real alternative is to make
citext's kluge even klugier.  In this patch, I cast the oidvector to text,
fix its contents with regexp_replace, and cast back to oidvector.  (Ugh!)

Since the aforementioned commit went into all active branches, we have to
fix this in all branches that contain the now-broken update script.

Per report from Eric Malm.

10 years agoFix FOR UPDATE NOWAIT on updated tuple chains
Alvaro Herrera [Wed, 27 Aug 2014 23:15:18 +0000 (19:15 -0400)]
Fix FOR UPDATE NOWAIT on updated tuple chains

If SELECT FOR UPDATE NOWAIT tries to lock a tuple that is concurrently
being updated, it might fail to honor its NOWAIT specification and block
instead of raising an error.

Fix by adding a no-wait flag to EvalPlanQualFetch which it can pass down
to heap_lock_tuple; also use it in EvalPlanQualFetch itself to avoid
blocking while waiting for a concurrent transaction.

Authors: Craig Ringer and Thomas Munro, tweaked by Álvaro
http://www.postgresql.org/message-id/51FB6703.9090801@2ndquadrant.com

Per Thomas Munro in the course of his SKIP LOCKED feature submission,
who also provided one of the isolation test specs.

Backpatch to 9.4, because that's as far back as it applies without
conflicts (although the bug goes all the way back).  To that branch also
backpatch Thomas Munro's new NOWAIT test cases, committed in master by
Heikki as commit 9ee16b49f0aac819bd4823d9b94485ef608b34e8 .

10 years agoFix Var handling for security barrier views
Stephen Frost [Wed, 27 Aug 2014 03:08:41 +0000 (23:08 -0400)]
Fix Var handling for security barrier views

In some cases, not all Vars were being correctly marked as having been
modified for updatable security barrier views, which resulted in invalid
plans (eg: when security barrier views were created over top of
inheiritance structures).

In passing, be sure to update both varattno and varonattno, as _equalVar
won't consider the Vars identical otherwise.  This isn't known to cause
any issues with updatable security barrier views, but was noticed as
missing while working on RLS and makes sense to get fixed.

Back-patch to 9.4 where updatable security barrier views were
introduced.

10 years agoFix superuser concurrent refresh of matview owned by another.
Kevin Grittner [Tue, 26 Aug 2014 15:00:42 +0000 (10:00 -0500)]
Fix superuser concurrent refresh of matview owned by another.

Use SECURITY_LOCAL_USERID_CHANGE while building temporary tables;
only escalate to SECURITY_RESTRICTED_OPERATION while potentially
running user-supplied code.  The more secure mode was preventing
temp table creation.  Add regression tests to cover this problem.

This fixes Bug #11208 reported by Bruno Emanuel de Andrade Silva.

Backpatch to 9.4, where the bug was introduced.

10 years agoupgrade docs: highlight pg_upgrade, warn about globals preservation
Bruce Momjian [Mon, 25 Aug 2014 19:34:50 +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

10 years agoRevert XactLockTableWait context setup in conditional multixact wait
Alvaro Herrera [Mon, 25 Aug 2014 19:33:19 +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
able wouldn't be able to see it.

Backpatch to 9.4, where this was added.

10 years agoFix typos in some error messages thrown by extension scripts when fed to psql.
Andres Freund [Mon, 25 Aug 2014 16:30:28 +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.

10 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

10 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.

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

10 years agoFix corner-case behaviors in JSON/JSONB field extraction operators.
Tom Lane [Fri, 22 Aug 2014 17:18:00 +0000 (13:18 -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.

10 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

10 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.

10 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.