]> granicus.if.org Git - postgresql/log
postgresql
11 years agoBe consistent about #define'ing configure symbols as "1" not empty.
Tom Lane [Sat, 15 Jun 2013 18:11:43 +0000 (14:11 -0400)]
Be consistent about #define'ing configure symbols as "1" not empty.

This is just neatnik-ism, since all the tests in the code are #ifdefs,
but we shouldn't specify symbols as "Define to 1 ..." and then not
actually define them that way.

11 years agoAdd :client_id automatic variable for custom pgbench scripts.
Heikki Linnakangas [Fri, 14 Jun 2013 20:31:44 +0000 (23:31 +0300)]
Add :client_id automatic variable for custom pgbench scripts.

This makes it easier to write custom scripts that have different logic for
each client.

Gurjeet Singh, with some changes by me.

11 years agoUpdate RELEASE_CHANGES to describe library version bumping more fully.
Tom Lane [Fri, 14 Jun 2013 18:53:23 +0000 (14:53 -0400)]
Update RELEASE_CHANGES to describe library version bumping more fully.

11 years agoStamp shared-library minor version numbers for 9.4.
Tom Lane [Fri, 14 Jun 2013 18:49:46 +0000 (14:49 -0400)]
Stamp shared-library minor version numbers for 9.4.

11 years agoStamp HEAD as 9.4devel.
Tom Lane [Fri, 14 Jun 2013 18:41:28 +0000 (14:41 -0400)]
Stamp HEAD as 9.4devel.

Let the hacking begin ...

11 years agoAvoid deadlocks during insertion into SP-GiST indexes.
Tom Lane [Fri, 14 Jun 2013 18:26:43 +0000 (14:26 -0400)]
Avoid deadlocks during insertion into SP-GiST indexes.

SP-GiST's original scheme for avoiding deadlocks during concurrent index
insertions doesn't work, as per report from Hailong Li, and there isn't any
evident way to make it work completely.  We could possibly lock individual
inner tuples instead of their whole pages, but preliminary experimentation
suggests that the performance penalty would be huge.  Instead, if we fail
to get a buffer lock while descending the tree, just restart the tree
descent altogether.  We keep the old tuple positioning rules, though, in
hopes of reducing the number of cases where this can happen.

Teodor Sigaev, somewhat edited by Tom Lane

11 years agoRemove special-case treatment of LOG severity level in standalone mode.
Tom Lane [Fri, 14 Jun 2013 03:15:15 +0000 (23:15 -0400)]
Remove special-case treatment of LOG severity level in standalone mode.

elog.c has historically treated LOG messages as low-priority during
bootstrap and standalone operation.  This has led to confusion and even
masked a bug, because the normal expectation of code authors is that
elog(LOG) will put something into the postmaster log, and that wasn't
happening during initdb.  So get rid of the special-case rule and make
the priority order the same as it is in normal operation.  To keep from
cluttering initdb's output and the behavior of a standalone backend,
tweak the severity level of three messages routinely issued by xlog.c
during startup and shutdown so that they won't appear in these cases.
Per my proposal back in December.

11 years agoRefactor checksumming code to make it easier to use externally.
Tom Lane [Fri, 14 Jun 2013 02:35:56 +0000 (22:35 -0400)]
Refactor checksumming code to make it easier to use externally.

pg_filedump and other external utility programs are likely to want to be
able to check Postgres page checksums.  To avoid messy duplication of code,
move the checksumming functionality into an exported header file, much as
we did awhile back for the CRC code.

In passing, get rid of an unportable assumption that a static char[] array
will be word-aligned, and do some other minor code beautification.

11 years agoPL/Python: Fix type mixup
Peter Eisentraut [Fri, 14 Jun 2013 01:42:42 +0000 (21:42 -0400)]
PL/Python: Fix type mixup

Memory was allocated based on the sizeof a type that was not the type of
the pointer that the result was being assigned to.  The types happen to
be of the same size, but it's still wrong.

11 years agoOnly install a portal's ResourceOwner if it actually has one.
Tom Lane [Thu, 13 Jun 2013 17:11:29 +0000 (13:11 -0400)]
Only install a portal's ResourceOwner if it actually has one.

In most scenarios a portal without a ResourceOwner is dead and not subject
to any further execution, but a portal for a cursor WITH HOLD remains in
existence with no ResourceOwner after the creating transaction is over.
In this situation, if we attempt to "execute" the portal directly to fetch
data from it, we were setting CurrentResourceOwner to NULL, leading to a
segfault if the datatype output code did anything that required a resource
owner (such as trying to fetch system catalog entries that weren't already
cached).  The case appears to be impossible to provoke with stock libpq,
but psqlODBC at least is able to cause it when working with held cursors.

Simplest fix is to just skip the assignment to CurrentResourceOwner, so
that any resources used by the data output operations will be managed by
the transaction-level resource owner instead.  For consistency I changed
all the places that install a portal's resowner as current, even though
some of them are probably not reachable with a held cursor's portal.

Per report from Joshua Berry (with thanks to Hiroshi Inoue for developing
a self-contained test case).  Back-patch to all supported versions.

11 years agoAvoid reading past datum end when parsing JSON.
Noah Misch [Wed, 12 Jun 2013 23:51:12 +0000 (19:51 -0400)]
Avoid reading past datum end when parsing JSON.

Several loops in the JSON parser examined a byte in memory just before
checking whether its address was in-bounds, so they could read one byte
beyond the datum's allocation.  A SIGSEGV is possible.  New in 9.3, so
no back-patch.

11 years agoAvoid reading below the start of a stack variable in tokenize_file().
Noah Misch [Wed, 12 Jun 2013 23:50:52 +0000 (19:50 -0400)]
Avoid reading below the start of a stack variable in tokenize_file().

We would wrongly overwrite the prior stack byte if it happened to
contain '\n' or '\r'.  New in 9.3, so no back-patch.

11 years agoDon't pass oidvector by value.
Noah Misch [Wed, 12 Jun 2013 23:50:37 +0000 (19:50 -0400)]
Don't pass oidvector by value.

Since the structure ends with a flexible array, doing so truncates any
vector having more than one element.  New in 9.3, so no back-patch.

11 years agoObserve array length in HaveVirtualXIDsDelayingChkpt().
Noah Misch [Wed, 12 Jun 2013 23:50:14 +0000 (19:50 -0400)]
Observe array length in HaveVirtualXIDsDelayingChkpt().

Since commit f21bb9cfb5646e1793dcc9c0ea697bab99afa523, this function
ignores the caller-provided length and loops until it finds a
terminator, which GetVirtualXIDsDelayingChkpt() never adds.  Restore the
previous loop control logic.  In passing, revert the addition of an
unused variable by the same commit, presumably a debugging relic.

11 years agoDon't use ordinary NULL-terminated strings as Name datums.
Noah Misch [Wed, 12 Jun 2013 23:49:50 +0000 (19:49 -0400)]
Don't use ordinary NULL-terminated strings as Name datums.

Consumers are entitled to read the full 64 bytes pertaining to a Name;
using a shorter NULL-terminated string leads to reading beyond the end
its allocation; a SIGSEGV is possible.  Use the frequent idiom of
copying to a NameData on the stack.  New in 9.3, so no back-patch.

11 years agoImprove updatability checking for views and foreign tables.
Tom Lane [Wed, 12 Jun 2013 21:52:54 +0000 (17:52 -0400)]
Improve updatability checking for views and foreign tables.

Extend the FDW API (which we already changed for 9.3) so that an FDW can
report whether specific foreign tables are insertable/updatable/deletable.
The default assumption continues to be that they're updatable if the
relevant executor callback function is supplied by the FDW, but finer
granularity is now possible.  As a test case, add an "updatable" option to
contrib/postgres_fdw.

This patch also fixes the information_schema views, which previously did
not think that foreign tables were ever updatable, and fixes
view_is_auto_updatable() so that a view on a foreign table can be
auto-updatable.

initdb forced due to changes in information_schema views and the functions
they rely on.  This is a bit unfortunate to do post-beta1, but if we don't
change this now then we'll have another API break for FDWs when we do
change it.

Dean Rasheed, somewhat editorialized on by Tom Lane

11 years agoFix unescaping of JSON Unicode escapes, especially for non-UTF8.
Andrew Dunstan [Wed, 12 Jun 2013 17:35:24 +0000 (13:35 -0400)]
Fix unescaping of JSON Unicode escapes, especially for non-UTF8.

Per discussion  on -hackers. We treat Unicode escapes when unescaping
them similarly to the way we treat them in PostgreSQL string literals.
Escapes in the ASCII range are always accepted, no matter what the
database encoding. Escapes for higher code points are only processed in
UTF8 databases, and attempts to process them in other databases will
result in an error. \u0000 is never unescaped, since it would result in
an impermissible null byte.

11 years agoImprove description of loread/lowrite.
Robert Haas [Wed, 12 Jun 2013 16:20:59 +0000 (12:20 -0400)]
Improve description of loread/lowrite.

Patch by me, reviewed by Tatsuo Ishii.

11 years agoFix cache flush hazard in cache_record_field_properties().
Tom Lane [Tue, 11 Jun 2013 21:26:42 +0000 (17:26 -0400)]
Fix cache flush hazard in cache_record_field_properties().

We need to increment the refcount on the composite type's cached tuple
descriptor while we do lookups of its column types.  Otherwise a cache
flush could occur and release the tuple descriptor before we're done with
it.  This fails reliably with -DCLOBBER_CACHE_ALWAYS, but the odds of a
failure in a production build seem rather low (since the pfree'd descriptor
typically wouldn't get scribbled on immediately).  That may explain the
lack of any previous reports.  Buildfarm issue noted by Christian Ullrich.

Back-patch to 9.1 where the bogus code was added.

11 years agoAdd description that loread()/lowrite() are corresponding to
Tatsuo Ishii [Tue, 11 Jun 2013 05:25:58 +0000 (14:25 +0900)]
Add description that loread()/lowrite() are corresponding to
lo_read()/lo_write() in libpq to avoid confusion.

11 years agoFix pg_isready to handle conninfo properly.
Fujii Masao [Mon, 10 Jun 2013 18:03:16 +0000 (03:03 +0900)]
Fix pg_isready to handle conninfo properly.

pg_isready displays the host name and the port number that it uses to connect
to the server. So far, pg_isready didn't use the conninfo specified in -d option
for calculating those host name and port number. This can lead to wrong display
to a user. This commit changes pg_isready so that it uses the conninfo for that
calculation.

Original patch by Phil Sorber, modified by me.

11 years agoFix ordering of obj id for Rules and EventTriggers in pg_dump.
Joe Conway [Mon, 10 Jun 2013 00:30:39 +0000 (17:30 -0700)]
Fix ordering of obj id for Rules and EventTriggers in pg_dump.

getSchemaData() must identify extension member objects and mark them
as not to be dumped. This must happen after reading all objects that can be
direct members of extensions, but before we begin to process table subsidiary
objects. Both rules and event triggers were wrong in this regard.

Backport rules portion of patch to 9.1 -- event triggers do not exist prior to 9.3.
Suggested fix by Tom Lane, initial complaint and patch by me.

11 years agoTweak postgres_fdw regression test so autovacuum doesn't change results.
Tom Lane [Sun, 9 Jun 2013 23:41:52 +0000 (19:41 -0400)]
Tweak postgres_fdw regression test so autovacuum doesn't change results.

Autovacuum occurring while the test runs could allow some of the inserts to
go into recycled space, thus changing the output ordering of later queries.
While we could complicate those queries to force sorting of their output
rows, it doesn't seem like that would make the test better in any
meaningful way, and conceivably it could hide unexpected diffs.  Instead,
tweak the affected queries so that the inserted rows aren't updated by the
following UPDATE.  Per buildfarm.

11 years agoRemove unnecessary restrictions about RowExprs in transformAExprIn().
Tom Lane [Sun, 9 Jun 2013 22:39:20 +0000 (18:39 -0400)]
Remove unnecessary restrictions about RowExprs in transformAExprIn().

When the existing code here was written, it made sense to special-case
RowExprs because that was the only way that we could handle row comparisons
at all.  Now that we have record_eq() and arrays of composites, the generic
logic for "scalar" types will in fact work on RowExprs too, so there's no
reason to throw error for combinations of RowExprs and other ways of
forming composite values, nor to ignore the possibility of using a
ScalarArrayOpExpr.  But keep using the old logic when comparing two
RowExprs, for consistency with the main transformAExprOp() logic.  (This
allows some cases with not-quite-identical rowtypes to succeed, so we might
get push-back if we removed it.)  Per bug #8198 from Rafal Rzepecki.

Back-patch to all supported branches, since this works fine as far back as
8.4.

Rafal Rzepecki and Tom Lane

11 years agoRemove ALTER DEFAULT PRIVILEGES' requirement of schema CREATE permissions.
Tom Lane [Sun, 9 Jun 2013 19:26:40 +0000 (15:26 -0400)]
Remove ALTER DEFAULT PRIVILEGES' requirement of schema CREATE permissions.

Per discussion, this restriction isn't needed for any real security reason,
and it seems to confuse people more often than it helps them.  It could
also result in some database states being unrestorable.  So just drop it.

Back-patch to 9.0, where ALTER DEFAULT PRIVILEGES was introduced.

11 years agoRemove fixed limit on the number of concurrent AllocateFile() requests.
Tom Lane [Sun, 9 Jun 2013 17:46:54 +0000 (13:46 -0400)]
Remove fixed limit on the number of concurrent AllocateFile() requests.

AllocateFile(), AllocateDir(), and some sister routines share a small array
for remembering requests, so that the files can be closed on transaction
failure.  Previously that array had a fixed size, MAX_ALLOCATED_DESCS (32).
While historically that had seemed sufficient, Steve Toutant pointed out
that this meant you couldn't scan more than 32 file_fdw foreign tables in
one query, because file_fdw depends on the COPY code which uses
AllocateFile().  There are probably other cases, or will be in the future,
where this nonconfigurable limit impedes users.

We can't completely remove any such limit, at least not without a lot of
work, since each such request requires a kernel file descriptor and most
platforms limit the number we can have.  (In principle we could
"virtualize" these descriptors, as fd.c already does for the main VFD pool,
but not without an additional layer of overhead and a lot of notational
impact on the calling code.)  But we can at least let the array size be
configurable.  Hence, change the code to allow up to max_safe_fds/2
allocated file requests.  On modern platforms this should allow several
hundred concurrent file_fdw scans, or more if one increases the value of
max_files_per_process.  To go much further than that, we'd need to do some
more work on the data structure, since the current code for closing
requests has potentially O(N^2) runtime; but it should still be all right
for request counts in this range.

Back-patch to 9.1 where contrib/file_fdw was introduced.

11 years agoDon't downcase non-ascii identifier chars in multi-byte encodings.
Andrew Dunstan [Sat, 8 Jun 2013 14:00:09 +0000 (10:00 -0400)]
Don't downcase non-ascii identifier chars in multi-byte encodings.

Long-standing code has called tolower() on identifier character bytes
with the high bit set. This is clearly an error and produces junk output
when the encoding is multi-byte. This patch therefore restricts this
activity to cases where there is a character with the high bit set AND
the encoding is single-byte.

There have been numerous gripes about this, most recently from Martin
Schäfer.

Backpatch to all live releases.

11 years agoHandle Unicode surrogate pairs correctly when processing JSON.
Andrew Dunstan [Sat, 8 Jun 2013 13:12:48 +0000 (09:12 -0400)]
Handle Unicode surrogate pairs correctly when processing JSON.

In 9.2, Unicode escape sequences are not analysed at all other than
to make sure that they are in the form \uXXXX. But in 9.3 many of the
new operators and functions try to turn JSON text values into text in
the server encoding, and this includes de-escaping Unicode escape
sequences. This processing had not taken into account the possibility
that this might contain a surrogate pair to designate a character
outside the BMP. That is now handled correctly.

This also enforces correct use of surrogate pairs, something that is not
done by the type's input routines. This fact is noted in the docs.

11 years agodoc: Fix <synopsis> in <term> markup
Peter Eisentraut [Sat, 8 Jun 2013 02:00:59 +0000 (22:00 -0400)]
doc: Fix <synopsis> in <term> markup

Although the DTD technically allows this, the resulting HTML is invalid
because it puts block elements inside inline elements.  DocBook 5.0 also
doesn't allow it anymore, so it's fair to assume that this was never
really intended to work.  Replace <synopsis> with <literal>, which is
the markup used elsewhere in the documentation in similar cases.

11 years agoCorrect the documentation of pg_rewrite.ev_attr.
Kevin Grittner [Fri, 7 Jun 2013 13:04:22 +0000 (08:04 -0500)]
Correct the documentation of pg_rewrite.ev_attr.

It claimed the value was always zero; it is really always -1.

Per report from Hari Babu

11 years agoMinor docs wordsmithing.
Tom Lane [Fri, 7 Jun 2013 04:08:02 +0000 (00:08 -0400)]
Minor docs wordsmithing.

Swap the order of a couple of phrases to clarify what the adjective
"subsequent" applies to.

Joshua Tolley

11 years agodoc: Clarify description of VALUES command
Peter Eisentraut [Fri, 7 Jun 2013 01:03:04 +0000 (21:03 -0400)]
doc: Clarify description of VALUES command

Greg Smith

11 years agoFix typo in comment.
Heikki Linnakangas [Thu, 6 Jun 2013 15:25:26 +0000 (18:25 +0300)]
Fix typo in comment.

11 years agoEnsure that XLOG_HEAP2_VISIBLE always targets an initialized page.
Robert Haas [Thu, 6 Jun 2013 14:03:37 +0000 (10:03 -0400)]
Ensure that XLOG_HEAP2_VISIBLE always targets an initialized page.

Andres Freund

11 years agopg_upgrade: document that --link should be used with --check
Bruce Momjian [Thu, 6 Jun 2013 14:13:55 +0000 (10:13 -0400)]
pg_upgrade:  document that --link should be used with --check
Backpatch to 9.2.

11 years agoPrevent pushing down WHERE clauses into unsafe UNION/INTERSECT nests.
Tom Lane [Thu, 6 Jun 2013 03:44:02 +0000 (23:44 -0400)]
Prevent pushing down WHERE clauses into unsafe UNION/INTERSECT nests.

The planner is aware that it mustn't push down upper-level quals into
subqueries if the quals reference subquery output columns that contain
set-returning functions or volatile functions, or are non-DISTINCT outputs
of a DISTINCT ON subquery.  However, it missed making this check when
there were one or more levels of UNION or INTERSECT above the dangerous
expression.  This could lead to "set-valued function called in context that
cannot accept a set" errors, as seen in bug #8213 from Eric Soroos, or to
silently wrong answers in the other cases.

To fix, refactor the checks so that we make the column-is-unsafe checks
during subquery_is_pushdown_safe(), which already has to recursively
inspect all arms of a set-operation tree.  This makes
qual_is_pushdown_safe() considerably simpler, at the cost that we will
spend some cycles checking output columns that possibly aren't referenced
in any upper qual.  But the cases where this code gets executed at all
are already nontrivial queries, so it's unlikely anybody will notice any
slowdown of planning.

This has been broken since commit 05f916e6add9726bf4ee046e4060c1b03c9961f2,
which makes the bug over ten years old.  A bit surprising nobody noticed it
before now.

11 years agoUpdate SQL features list
Peter Eisentraut [Thu, 6 Jun 2013 02:05:18 +0000 (22:05 -0400)]
Update SQL features list

11 years agoPut analyze_keyword back in explain_option_name production.
Tom Lane [Wed, 5 Jun 2013 17:32:53 +0000 (13:32 -0400)]
Put analyze_keyword back in explain_option_name production.

In commit 2c92edad48796119c83d7dbe6c33425d1924626d, I broke "EXPLAIN
(ANALYZE)" syntax, because I mistakenly thought that ANALYZE/ANALYSE were
only partially reserved and thus would be included in NonReservedWord;
but actually they're fully reserved so they still need to be called out
here.

A nicer solution would be to demote these words to type_func_name_keyword
status (they can't be less than that because of "VACUUM [ANALYZE] ColId").
While that works fine so far as the core grammar is concerned, it breaks
ECPG's grammar for reasons I don't have time to isolate at the moment.
So do this for the time being.

Per report from Kevin Grittner.  Back-patch to 9.0, like the previous
commit.

11 years agoProvide better message when CREATE EXTENSION can't find a target schema.
Tom Lane [Tue, 4 Jun 2013 21:22:29 +0000 (17:22 -0400)]
Provide better message when CREATE EXTENSION can't find a target schema.

The new message (and SQLSTATE) matches the corresponding error cases in
namespace.c.

This was thought to be a "can't happen" case when extension.c was written,
so we didn't think hard about how to report it.  But it definitely can
happen in 9.2 and later, since we no longer require search_path to contain
any valid schema names.  It's probably also possible in 9.1 if search_path
came from a noninteractive source.  So, back-patch to all releases
containing this code.

Per report from Sean Chittenden, though this isn't exactly his patch.

11 years agoAdd ARM64 (aarch64) support to s_lock.h.
Tom Lane [Tue, 4 Jun 2013 19:42:02 +0000 (15:42 -0400)]
Add ARM64 (aarch64) support to s_lock.h.

Use the same gcc atomic functions as we do on newer ARM chips.
(Basically this is a copy and paste of the __arm__ code block,
but omitting the SWPB option since that definitely won't work.)

Back-patch to 9.2.  The patch would work further back, but we'd also
need to update config.guess/config.sub in older branches to make them
build out-of-the-box, and there hasn't been demand for it.

Mark Salter

11 years agoFix memory leak in LogStandbySnapshot().
Tom Lane [Tue, 4 Jun 2013 18:58:46 +0000 (14:58 -0400)]
Fix memory leak in LogStandbySnapshot().

The array allocated by GetRunningTransactionLocks() needs to be pfree'd
when we're done with it.  Otherwise we leak some memory during each
checkpoint, if wal_level = hot_standby.  This manifests as memory bloat
in the checkpointer process, or in bgwriter in versions before we made
the checkpointer separate.

Reported and fixed by Naoya Anzai.  Back-patch to 9.0 where the issue
was introduced.

In passing, improve comments for GetRunningTransactionLocks(), and add
an Assert that we didn't overrun the palloc'd array.

11 years agoFix off-by-one in pg_xlogdump -r option.
Heikki Linnakangas [Tue, 4 Jun 2013 15:51:43 +0000 (18:51 +0300)]
Fix off-by-one in pg_xlogdump -r option.

Because of the bug, -r would not accept the rmgr with the highest ID.

11 years agoAdd semicolons to eval'd strings to hide a minor Perl behavioral change.
Tom Lane [Mon, 3 Jun 2013 18:19:26 +0000 (14:19 -0400)]
Add semicolons to eval'd strings to hide a minor Perl behavioral change.

"eval q{foo}" used to complain that the error was on line 2 of the eval'd
string, because eval internally tacked on "\n;" so that the end of the
erroneous command was indeed on line 2.  But as of Perl 5.18 it more
sanely says that the error is on line 1.  To avoid Perl-version-dependent
regression test results, use "eval q{foo;}" instead in the two places
where this matters.  Per buildfarm.

Since people might try to use newer Perl versions with older PG releases,
back-patch as far as 9.0 where these test cases were added.

11 years agoPut back allow_system_table_mods check in heap_create().
Heikki Linnakangas [Mon, 3 Jun 2013 14:22:31 +0000 (17:22 +0300)]
Put back allow_system_table_mods check in heap_create().

This reverts commit a475c6036752c26dca538632b68fd2cc592976b7.

Erik Rijkers reported back in January 2013 that after the patch, if you do
"pg_dump -t myschema.mytable" to dump a single table, and restore that in
a database where myschema does not exist, the table is silently created in
pg_catalog instead. That is because pg_dump uses
"SET search_path=myschema, pg_catalog" to set schema the table is created
in. While allow_system_table_mods is not a very elegant solution to this,
we can't leave it as it is, so for now, revert it back to the way it was
previously.

11 years agoAdditional spelling corrections
Stephen Frost [Mon, 3 Jun 2013 12:40:27 +0000 (08:40 -0400)]
Additional spelling corrections

A few more minor spelling corrections, no functional changes.

Thom Brown

11 years agoCode review of recycling WAL segments in a restartpoint.
Heikki Linnakangas [Mon, 3 Jun 2013 06:25:12 +0000 (09:25 +0300)]
Code review of recycling WAL segments in a restartpoint.

Seems cleaner to get the currently-replayed TLI in the same call to
GetXLogReplayRecPtr that we get the WAL position. Make it more clear in the
comment what the code does when recovery has already ended
(RecoveryInProgress() will set ThisTimeLineID in that case). Finally, make
resetting ThisTimeLineID afterwards more explicit.

11 years agoAllow type_func_name_keywords in some places where they weren't before.
Tom Lane [Mon, 3 Jun 2013 00:09:20 +0000 (20:09 -0400)]
Allow type_func_name_keywords in some places where they weren't before.

This change makes type_func_name_keywords less reserved than they were
before, by allowing them for role names, language names, EXPLAIN and COPY
options, and SET values for GUCs; which are all places where few if any
actual keywords could appear instead, so no new ambiguities are introduced.

The main driver for this change is to allow "COPY ... (FORMAT BINARY)"
to work without quoting the word "binary".  That is an inconsistency that
has been complained of repeatedly over the years (at least by Pavel Golub,
Kurt Lidl, and Simon Riggs); but we hadn't thought of any non-ugly solution
until now.

Back-patch to 9.0 where the COPY (FORMAT BINARY) syntax was introduced.

11 years agoAnother man page whitespace fix
Peter Eisentraut [Sun, 2 Jun 2013 02:22:02 +0000 (22:22 -0400)]
Another man page whitespace fix

11 years agoFix whitespace issues in the man pages
Peter Eisentraut [Sun, 2 Jun 2013 02:03:02 +0000 (22:03 -0400)]
Fix whitespace issues in the man pages

See 00b0c73f1f2b98a7d09de63aaa14d6498ac521ae for an explanation.

11 years agoFix unportable usage of isspace().
Tom Lane [Sat, 1 Jun 2013 17:58:23 +0000 (13:58 -0400)]
Fix unportable usage of isspace().

Must cast char argument to unsigned to avoid doing the wrong thing
with high-bit-set characters.  Oversight in commit
30b5ede7157e34e77c7914b8ecfd55aa8da6edc3.

11 years agoMinor spelling fixes
Stephen Frost [Sat, 1 Jun 2013 14:18:59 +0000 (10:18 -0400)]
Minor spelling fixes

Fix a few spelling mistakes.

Per bug report #8193 from Lajos Veres.

11 years agoPost-pgindent cleanup
Stephen Frost [Sat, 1 Jun 2013 13:38:15 +0000 (09:38 -0400)]
Post-pgindent cleanup

Make slightly better decisions about indentation than what pgindent
is capable of.  Mostly breaking out long function calls into one
line per argument, with a few other minor adjustments.

No functional changes- all whitespace.
pgindent ran cleanly (didn't change anything) after.
Passes all regressions.

11 years agodoc: Remove paragraph about typesetting conventions
Peter Eisentraut [Sat, 1 Jun 2013 02:42:27 +0000 (22:42 -0400)]
doc: Remove paragraph about typesetting conventions

They no longer match reality with the web site style sheets, and it is
difficult to keep the up to date in a CSS world.

11 years agoDon't emit non-canonical empty arrays in array_remove().
Noah Misch [Sat, 1 Jun 2013 01:50:59 +0000 (21:50 -0400)]
Don't emit non-canonical empty arrays in array_remove().

Dean Rasheed

11 years agoAdd new source files to nls.mk
Peter Eisentraut [Sat, 1 Jun 2013 00:03:39 +0000 (20:03 -0400)]
Add new source files to nls.mk

11 years agodoc: Fix claim that query is passed as ASCII text
Peter Eisentraut [Fri, 31 May 2013 01:09:27 +0000 (21:09 -0400)]
doc: Fix claim that query is passed as ASCII text

Ian Lawrence Barwick

11 years agoRemove whitespace from end of lines
Peter Eisentraut [Fri, 31 May 2013 01:05:07 +0000 (21:05 -0400)]
Remove whitespace from end of lines

11 years agoMinor spell checking
Peter Eisentraut [Fri, 31 May 2013 00:56:58 +0000 (20:56 -0400)]
Minor spell checking

11 years agopostgresql.conf.sample: Improve whitespace
Peter Eisentraut [Thu, 30 May 2013 02:00:13 +0000 (22:00 -0400)]
postgresql.conf.sample: Improve whitespace

11 years agopgindent run for release 9.3
Bruce Momjian [Wed, 29 May 2013 20:58:43 +0000 (16:58 -0400)]
pgindent run for release 9.3
This is the first run of the Perl-based pgindent script.  Also update
pgindent instructions.

11 years agoDocument auto_explain.log_timing.
Robert Haas [Wed, 29 May 2013 11:11:21 +0000 (07:11 -0400)]
Document auto_explain.log_timing.

Tomas Vondra

11 years agopg_upgrade docs: mention need to set parameters for vacuumdb.
Bruce Momjian [Wed, 29 May 2013 02:54:28 +0000 (22:54 -0400)]
pg_upgrade docs:  mention need to set parameters for vacuumdb.

11 years agoDocumentation fix for ALTER TYPE .. RENAME
Stephen Frost [Mon, 27 May 2013 15:12:54 +0000 (11:12 -0400)]
Documentation fix for ALTER TYPE .. RENAME

The documentation for ALTER TYPE .. RENAME claimed to support a
RESTRICT/CASCADE option at the 'type' level, which wasn't implemented
and doesn't make a whole lot of sense to begin with.  What is supported,
and previously undocumented, is

ALTER TYPE .. RENAME ATTRIBUTE .. RESTRICT/CASCADE.

I've updated the documentation and back-patched this to 9.1 where it was
first introduced.

11 years agoRemove pageinspect--1.0.sql
Heikki Linnakangas [Fri, 24 May 2013 12:00:34 +0000 (08:00 -0400)]
Remove pageinspect--1.0.sql

We're not installing it anymore.

Michael Paquier

11 years agoFix typo in comment.
Robert Haas [Thu, 23 May 2013 15:34:30 +0000 (11:34 -0400)]
Fix typo in comment.

Pavan Deolasee

11 years agoPrint line number correctly in COPY.
Heikki Linnakangas [Thu, 23 May 2013 11:49:59 +0000 (07:49 -0400)]
Print line number correctly in COPY.

When COPY uses the multi-insert method to insert a batch of tuples into the
heap at a time, incorrect line number was printed if something went wrong in
inserting the index tuples (primary key failure, for exampl), or processing
after row triggers.

Fixes bug #8173 reported by Lloyd Albin. Backpatch to 9.2, where the multi-
insert code was added.

11 years ago9.3 release notes: improve cached plan mention
Bruce Momjian [Tue, 21 May 2013 20:42:24 +0000 (16:42 -0400)]
9.3 release notes:  improve cached plan mention
Per suggestion from Tom Lane.

11 years agoAfter fast promotion use CHECKPOINT_FORCE
Simon Riggs [Tue, 21 May 2013 20:27:12 +0000 (21:27 +0100)]
After fast promotion use CHECKPOINT_FORCE

Not necessary for correctness, just to make
log_checkpoints output look less singular.

Requested by Fujii Masao

11 years agoMaintain ThisTimeLineID correctly in checkpointer
Simon Riggs [Tue, 21 May 2013 20:17:04 +0000 (21:17 +0100)]
Maintain ThisTimeLineID correctly in checkpointer

checkpointer needs to reset ThisTimeLineID after
a restartpoint to allow installing/recycling new
WAL files. If recovery has already ended this
would leave ThisTimeLineID set incorrectly and
so we must reset it otherwise later checkpoints
do not have the correct timeline.

Bug report by Heikki Linnakangas.
Further investigation by Heikki and myself.

11 years ago9.3 release notes: fix SGML markup for DROP TABLE IF EXISTS
Bruce Momjian [Tue, 21 May 2013 12:06:32 +0000 (08:06 -0400)]
9.3 release notes:  fix SGML markup for DROP TABLE IF EXISTS

11 years ago9.3 release docs: fix DROP TABLE IF EXISTS
Bruce Momjian [Tue, 21 May 2013 02:38:37 +0000 (22:38 -0400)]
9.3 release docs: fix DROP TABLE IF EXISTS
Patch from Joe Abbate.

11 years agoDocumentation spell checking and markup improvements
Peter Eisentraut [Tue, 21 May 2013 01:13:13 +0000 (21:13 -0400)]
Documentation spell checking and markup improvements

11 years agoFix escaping in generated recovery.conf file.
Heikki Linnakangas [Mon, 20 May 2013 16:34:27 +0000 (19:34 +0300)]
Fix escaping in generated recovery.conf file.

In the primary_conninfo line that "pg_basebackup -R" generates, single
quotes in parameter values need to be escaped into \\'; the libpq parser
requires the quotes to be escaped into \', and recovery.conf parser requires
the \ to be escaped into \\.

Also, don't quote parameter values unnecessarily, to make the connection
string prettier. Most options in a libpq connection string don't need
quoting.

Reported by Hari Babu, closer analysis by Zoltan Boszormenyi, although I
didn't use his patch.

11 years agoClarify documentation of EXPLAIN (TIMING OFF) option.
Tom Lane [Mon, 20 May 2013 02:03:32 +0000 (22:03 -0400)]
Clarify documentation of EXPLAIN (TIMING OFF) option.

Clarify that this option doesn't suppress measurement of the statement's
total runtime.

Greg Smith

11 years agoInit crash recovery using the latest available TLI
Simon Riggs [Sun, 19 May 2013 16:31:07 +0000 (17:31 +0100)]
Init crash recovery using the latest available TLI

This simplifies the handling of crashes after fast promotion and various
minor cases that can exist in short timing windows around that case.

Broad fix to bug reported by Michael Paquier on -hackers,
approach prompted by Heikki Linnakangas

11 years agoEmit msg correctly for timeline-crossing crash
Simon Riggs [Sun, 19 May 2013 16:00:18 +0000 (17:00 +0100)]
Emit msg correctly for timeline-crossing crash

11 years agoRemove single space on end of a line in xlog.c
Simon Riggs [Sun, 19 May 2013 14:38:47 +0000 (15:38 +0100)]
Remove single space on end of a line in xlog.c

Michael Paquier

11 years agoRemove unused regression test files.
Heikki Linnakangas [Sat, 18 May 2013 19:30:20 +0000 (22:30 +0300)]
Remove unused regression test files.

euc_* and mule_internal test cases were identical to the ones in
src/test/mb. sql_ascii didn't exist elsewhere, but has been broken since
2001, and doesn't seem very interesting anyway. drop.sql hasn't been used
since 2000, when regress.sh was removed.

11 years agorelease docs: mention PL/pgSQL as supporting event triggers in PG 9.3
Bruce Momjian [Sat, 18 May 2013 15:01:55 +0000 (11:01 -0400)]
release docs:  mention PL/pgSQL as supporting event triggers in PG 9.3

11 years agoFix crash when trying to display a NOTIFY rule action.
Tom Lane [Thu, 16 May 2013 20:47:26 +0000 (16:47 -0400)]
Fix crash when trying to display a NOTIFY rule action.

Fixes oversight in commit 2ffa740be9d96a3743ecb7e42391c53d0760c65a.
Per report from Josh Kupershmidt.

I think we've broken this case before, so let's add a regression test
this time.

11 years agoFix fd.c to preserve errno where needed.
Tom Lane [Thu, 16 May 2013 19:04:31 +0000 (15:04 -0400)]
Fix fd.c to preserve errno where needed.

PathNameOpenFile failed to ensure that the correct value of errno was
returned to its caller after a failure (because it incorrectly supposed
that free() can never change errno).  In some cases this would result
in a user-visible failure because an expected ENOENT errno was replaced
with something else.  Bogus EINVAL failures have been observed on OS X,
for example.

There were also a couple of places that could mangle an important value
of errno if FDDEBUG was defined.  While the usefulness of that debug
support is highly debatable, we might as well make it safe to use,
so add errno save/restore logic to the DO_DB macro.

Per bug #8167 from Nelson Minar, diagnosed by RhodiumToad.
Back-patch to all supported branches.

11 years agoFix some uses of "the quick brown fox".
Tom Lane [Thu, 16 May 2013 16:30:41 +0000 (12:30 -0400)]
Fix some uses of "the quick brown fox".

If we're going to quote a well-known pangram, we should quote it
accurately.  Per gripe from Thom Brown.

11 years agoAllow CREATE FOREIGN TABLE to include SERIAL columns.
Tom Lane [Wed, 15 May 2013 23:03:29 +0000 (19:03 -0400)]
Allow CREATE FOREIGN TABLE to include SERIAL columns.

The behavior is that the required sequence is created locally, which is
appropriate because the default expression will be evaluated locally.
Per gripe from Brad Nicholson that this case was refused with a confusing
error message.  We could have improved the error message but it seems
better to just allow the case.

Also, remove ALTER TABLE's arbitrary prohibition against being applied to
foreign tables, which was pretty inconsistent considering we allow it for
views, sequences, and other relation types that aren't even called tables.
This is needed to avoid breaking pg_dump, which sometimes emits column
defaults using separate ALTER TABLE commands.  (I think this can happen
even when the default is not associated with a sequence, so that was a
pre-existing bug once we allowed column defaults for foreign tables.)

11 years agodoc: Add \dm command to psql man page
Peter Eisentraut [Wed, 15 May 2013 01:12:34 +0000 (21:12 -0400)]
doc: Add \dm command to psql man page

11 years agodoc: Fix some whitespace issues in the man pages
Peter Eisentraut [Tue, 14 May 2013 01:59:39 +0000 (21:59 -0400)]
doc: Fix some whitespace issues in the man pages

11 years agopg_upgrade: Replace tabs in output string constants by spaces
Peter Eisentraut [Tue, 14 May 2013 01:42:19 +0000 (21:42 -0400)]
pg_upgrade: Replace tabs in output string constants by spaces

11 years agodoc: Fix order of options on pgbench man page
Peter Eisentraut [Tue, 14 May 2013 01:37:01 +0000 (21:37 -0400)]
doc: Fix order of options on pgbench man page

11 years agoFix handling of OID wraparound while in standalone mode.
Tom Lane [Mon, 13 May 2013 19:40:16 +0000 (15:40 -0400)]
Fix handling of OID wraparound while in standalone mode.

If OID wraparound should occur while in standalone mode (unlikely but
possible), we want to advance the counter to FirstNormalObjectId not
FirstBootstrapObjectId.  Otherwise, user objects might be created with OIDs
in the system-reserved range.  That isn't immediately harmful but it poses
a risk of conflicts during future pg_upgrade operations.

Noted by Andres Freund.  Back-patch to all supported branches, since all of
them are supported sources for pg_upgrade operations.

11 years agoFix handling of strict non-set functions with NULLs in set-valued inputs.
Tom Lane [Sun, 12 May 2013 17:08:12 +0000 (13:08 -0400)]
Fix handling of strict non-set functions with NULLs in set-valued inputs.

In a construct like "select plain_function(set_returning_function(...))",
the plain function is applied to each output row of the SRF successively.
If some of the SRF outputs are NULL, and the plain function is strict,
you'd expect to get NULL results for such rows ... but what actually
happened was that such rows were omitted entirely from the result set.
This was due to confusion of this case with what should happen for nested
set-returning functions; a strict SRF is indeed supposed to yield an empty
set for null input.  Per bug #8150 from Erwin Brandstetter.

Although this has been broken forever, we're not back-patching because
of the possibility that some apps out there expect the incorrect behavior.
This change should be listed as a possible incompatibility in the 9.3
release notes.

11 years agopgbench: Fix order of options in --help output
Peter Eisentraut [Sun, 12 May 2013 01:57:54 +0000 (21:57 -0400)]
pgbench: Fix order of options in --help output

11 years agopg_xlogdump: Improve --help output
Peter Eisentraut [Sun, 12 May 2013 01:55:37 +0000 (21:55 -0400)]
pg_xlogdump: Improve --help output

11 years agoFix to_number() to correctly ignore thousands separator when it's '.'.
Tom Lane [Sat, 11 May 2013 20:35:03 +0000 (16:35 -0400)]
Fix to_number() to correctly ignore thousands separator when it's '.'.

The existing code in NUM_numpart_from_char has hard-wired logic to treat
'.' as decimal point, even when we're using a locale-aware format string
and the locale says that '.' is the thousands separator.  This results in
clearly wrong answers in FM mode (where we must be able to identify the
decimal point location), as per bug report from Patryk Kordylewski.

Since the initialization code in NUM_prepare_locale already sets up
Np->decimal as either the locale decimal-point string or "." depending
on which decimal-point format code was used, there's really no need to
have any extra logic at all in NUM_numpart_from_char: we only need to
test for a match to Np->decimal.

(Note: AFAICS there's nothing in here that explicitly checks for thousands
separators --- rather, any unmatched character is silently skipped over.
That's pretty bogus IMO but it's not the issue being complained of.)

This is a longstanding bug, but it's possible that some existing apps
are depending on '.' being recognized as decimal point even when using
a D format code.  Hence, no back-patch.  We should probably list this
as a potential incompatibility in the 9.3 release notes.

11 years agoFix buildfarm incompatibility in updated pg_upgrade test script.
Tom Lane [Sat, 11 May 2013 20:14:19 +0000 (16:14 -0400)]
Fix buildfarm incompatibility in updated pg_upgrade test script.

Looks like some versions of the buildfarm script try to set the port via
--port in $EXTRA_REGRESS_OPTS.  Override that ...

11 years agoMake pg_upgrade's test script attempt to select a non-conflicting port.
Tom Lane [Sat, 11 May 2013 18:22:18 +0000 (14:22 -0400)]
Make pg_upgrade's test script attempt to select a non-conflicting port.

Previously, the port number used in this test script was hard-wired at
pg_upgrade's default of 50432; which is not so great because parallel build
runs might conflict.  Commit 3d53173e20d151341f894f79d556768c845ba3e4
removed this setting for the postmasters started by the script proper
(not by pg_upgrade), which didn't do anything to fix that problem and also
guaranteed a failure if there was a live postmaster at the build's default
port number.  Instead, select a non-conflicting temporary port number in
the same way that pg_regress.c does.  (Its method isn't entirely
bulletproof, but given the lack of complaints I'm not going to worry
about that today.)

In passing, unset MAKEFLAGS and MAKELEVEL to avoid problems with the
script's internal invocations of make, for the same reason pg_regress.c
does: it could cause problems in a parallel make.

11 years agoUpdate CREATE FUNCTION documentation about argument names.
Tom Lane [Sat, 11 May 2013 16:07:47 +0000 (12:07 -0400)]
Update CREATE FUNCTION documentation about argument names.

The 9.2 patch that added argument name support in SQL-language functions
missed updating a parenthetical comment about that in the CREATE FUNCTION
reference page.  Noted by Erwin Brandstetter.

11 years agoGuard against input_rows == 0 in estimate_num_groups().
Tom Lane [Fri, 10 May 2013 21:15:30 +0000 (17:15 -0400)]
Guard against input_rows == 0 in estimate_num_groups().

This case doesn't normally happen, because the planner usually clamps
all row estimates to at least one row; but I found that it can arise
when dealing with relations excluded by constraints.  Without a defense,
estimate_num_groups() can return zero, which leads to divisions by zero
inside the planner as well as assertion failures in the executor.

An alternative fix would be to change set_dummy_rel_pathlist() to make
the size estimate for a dummy relation 1 row instead of 0, but that seemed
pretty ugly; and probably someday we'll want to drop the convention that
the minimum rowcount estimate is 1 row.

Back-patch to 8.4, as the problem can be demonstrated that far back.

11 years agoFix pgp_pub_decrypt() so it works for secret keys with passwords.
Tom Lane [Fri, 10 May 2013 17:06:48 +0000 (13:06 -0400)]
Fix pgp_pub_decrypt() so it works for secret keys with passwords.

Per report from Keith Fiske.

Marko Kreen

11 years agoFix management of fn_extra caching during repeated GiST index scans.
Tom Lane [Fri, 10 May 2013 03:08:19 +0000 (23:08 -0400)]
Fix management of fn_extra caching during repeated GiST index scans.

Commit d22a09dc70f9830fa78c1cd1a3a453e4e473d354 introduced official support
for GiST consistentFns that want to cache data using the FmgrInfo fn_extra
pointer: the idea was to preserve the cached values across gistrescan(),
whereas formerly they'd been leaked.  However, there was an oversight in
that, namely that multiple scan keys might reference the same column's
consistentFn; the code would result in propagating the same cache value
into multiple scan keys, resulting in crashes or wrong answers.  Use a
separate array instead to ensure that each scan key keeps its own state.

Per bug #8143 from Joel Roller.  Back-patch to 9.2 where the bug was
introduced.

11 years agoUpdate key words table for 9.3
Peter Eisentraut [Fri, 10 May 2013 02:26:04 +0000 (22:26 -0400)]
Update key words table for 9.3

11 years agoRemove make_keywords
Peter Eisentraut [Fri, 10 May 2013 02:21:43 +0000 (22:21 -0400)]
Remove make_keywords

It is not used anymore.