]> granicus.if.org Git - postgresql/log
postgresql
12 years agoDocument that only user-defined columns are expanded by SELECT *.
Bruce Momjian [Sat, 10 Sep 2011 14:45:55 +0000 (10:45 -0400)]
Document that only user-defined columns are expanded by SELECT *.

12 years agoRemove unnecessary MATCH FULL specification in example.
Bruce Momjian [Sat, 10 Sep 2011 13:24:05 +0000 (09:24 -0400)]
Remove unnecessary MATCH FULL specification in example.

Reported by Grzegorz Szpetkowski.

12 years agoTry to un-break MSVC build.
Tom Lane [Sat, 10 Sep 2011 02:57:08 +0000 (22:57 -0400)]
Try to un-break MSVC build.

I thought we had enough infrastructure to absorb CPPFLAGS changes from
the makefiles, but buildfarm says otherwise.

12 years agoSimplify handling of the timezone GUC by making initdb choose the default.
Tom Lane [Fri, 9 Sep 2011 21:59:11 +0000 (17:59 -0400)]
Simplify handling of the timezone GUC by making initdb choose the default.

We were doing some amazingly complicated things in order to avoid running
the very expensive identify_system_timezone() procedure during GUC
initialization.  But there is an obvious fix for that, which is to do it
once during initdb and have initdb install the system-specific default into
postgresql.conf, as it already does for most other GUC variables that need
system-environment-dependent defaults.  This means that the timezone (and
log_timezone) settings no longer have any magic behavior in the server.
Per discussion.

12 years agoMove Timestamp/Interval typedefs and basic macros into datatype/timestamp.h.
Tom Lane [Fri, 9 Sep 2011 17:23:41 +0000 (13:23 -0400)]
Move Timestamp/Interval typedefs and basic macros into datatype/timestamp.h.

As per my recent proposal, this refactors things so that these typedefs and
macros are available in a header that can be included in frontend-ish code.
I also changed various headers that were undesirably including
utils/timestamp.h to include datatype/timestamp.h instead.  Unsurprisingly,
this showed that half the system was getting utils/timestamp.h by way of
xlog.h.

No actual code changes here, just header refactoring.

12 years agoround() is not portable. Use rint().
Tom Lane [Thu, 8 Sep 2011 20:37:40 +0000 (16:37 -0400)]
round() is not portable.  Use rint().

12 years agoTweak string for uniformity
Alvaro Herrera [Wed, 7 Sep 2011 21:19:32 +0000 (18:19 -0300)]
Tweak string for uniformity

12 years agoAdd missing format argument to ecpg_log() call
Peter Eisentraut [Thu, 8 Sep 2011 19:09:08 +0000 (22:09 +0300)]
Add missing format argument to ecpg_log() call

12 years agoFix typo and reword the sentence.
Heikki Linnakangas [Thu, 8 Sep 2011 15:17:57 +0000 (18:17 +0300)]
Fix typo and reword the sentence.

12 years agoBuffering GiST index build algorithm.
Heikki Linnakangas [Thu, 8 Sep 2011 14:51:23 +0000 (17:51 +0300)]
Buffering GiST index build algorithm.

When building a GiST index that doesn't fit in cache, buffers are attached
to some internal nodes in the index. This speeds up the build by avoiding
random I/O that would otherwise be needed to traverse all the way down the
tree to the find right leaf page for tuple.

Alexander Korotkov

12 years agoOne last round of copy-editing for the 9.1 release notes.
Tom Lane [Thu, 8 Sep 2011 04:53:11 +0000 (00:53 -0400)]
One last round of copy-editing for the 9.1 release notes.

Also set the documented release date to 2011-09-12.

12 years agoFix corner case bug in numeric to_char().
Tom Lane [Wed, 7 Sep 2011 21:06:10 +0000 (17:06 -0400)]
Fix corner case bug in numeric to_char().

Trailing-zero stripping applied by the FM specifier could strip zeroes
to the left of the decimal point, for a format with no digit positions
after the decimal point (such as "FM999.").

Reported and diagnosed by Marti Raudsepp, though I didn't use his patch.

12 years agoAllow bcc32 and win32 batch files to compile libpq.
Bruce Momjian [Wed, 7 Sep 2011 19:43:50 +0000 (15:43 -0400)]
Allow bcc32 and win32 batch files to compile libpq.

Backpatch to 9.1.

By Hiroshi Saito

12 years agoIn pg_upgrade, disallow migration of 8.3 clusters using contrib/ltree
Bruce Momjian [Wed, 7 Sep 2011 18:42:34 +0000 (14:42 -0400)]
In pg_upgrade, disallow migration of 8.3 clusters using contrib/ltree
because its internal format was changed in 8.4.

Backpatch to 9.0 and 9.1.

Report by depesz, diagnosis by Tom.

12 years agoFix typo in error message.
Tom Lane [Wed, 7 Sep 2011 17:29:26 +0000 (13:29 -0400)]
Fix typo in error message.

Per Euler Taveira de Oliveira.

12 years agoFix get_name_for_var_field() to deal with RECORD Params.
Tom Lane [Wed, 7 Sep 2011 17:01:15 +0000 (13:01 -0400)]
Fix get_name_for_var_field() to deal with RECORD Params.

With 9.1's use of Params to pass down values from NestLoop join nodes
to their inner plans, it is possible for a Param to have type RECORD, in
which case the set of fields comprising the value isn't determinable by
inspection of the Param alone.  However, just as with a Var of type RECORD,
we can find out what we need to know if we can locate the expression that
the Param represents.  We already knew how to do this in get_parameter(),
but I'd overlooked the need to be able to cope in get_name_for_var_field(),
which led to EXPLAIN failing with "record type has not been registered".

To fix, refactor the search code in get_parameter() so it can be used by
both functions.

Per report from Marti Raudsepp.

12 years agoHave pgrminclude skip files that use CppAsString2 because CppAsString2
Bruce Momjian [Wed, 7 Sep 2011 16:59:17 +0000 (12:59 -0400)]
Have pgrminclude skip files that use CppAsString2 because CppAsString2
will expaned undefined identifiers.

12 years agoFix bug introduced by pgrminclude where the tablespace version name was
Bruce Momjian [Wed, 7 Sep 2011 16:41:16 +0000 (12:41 -0400)]
Fix bug introduced by pgrminclude where the tablespace version name was
not expanded.

Bump catalog version number to force initdb for all tablespaces.

12 years agoFix to_date() and to_timestamp() to handle year masks of length < 4 so
Bruce Momjian [Wed, 7 Sep 2011 13:47:51 +0000 (09:47 -0400)]
Fix to_date() and to_timestamp() to handle year masks of length < 4 so
they wrap toward year 2020, rather than the inconsistent behavior we had
before.

12 years agoRevert documentation patch about NEW/OLD and triggers.
Bruce Momjian [Wed, 7 Sep 2011 13:24:01 +0000 (09:24 -0400)]
Revert documentation patch about NEW/OLD and triggers.

Backpatch to 9.0 and 9.1.

Patch from Josh Kupershmidt.

12 years agoPartially revoke attempt to improve performance with many savepoints.
Simon Riggs [Wed, 7 Sep 2011 11:11:26 +0000 (12:11 +0100)]
Partially revoke attempt to improve performance with many savepoints.
Maintain difference between subtransaction release and commit introduced
by earlier patch.

12 years agoEmit cascaded standby message on shutdown only when appropriate.
Simon Riggs [Wed, 7 Sep 2011 08:09:47 +0000 (09:09 +0100)]
Emit cascaded standby message on shutdown only when appropriate.
Adds additional test for active walsenders and closes a race
condition for when we failover when a new walsender was connecting.

Reported and fixed bu Fujii Masao. Review by Heikki Linnakangas

12 years agoProperly document the existance of OLD/NEW trigger pl/pgsql trigger
Bruce Momjian [Wed, 7 Sep 2011 02:54:16 +0000 (22:54 -0400)]
Properly document the existance of OLD/NEW trigger pl/pgsql trigger
fields.

Backpatch to 9.0 and 9.1.

Report from Pavel Stehule, patch from Josh Kupershmidt

12 years agoFix spelling mistake in pgpass documentation change.
Bruce Momjian [Tue, 6 Sep 2011 23:42:46 +0000 (19:42 -0400)]
Fix spelling mistake in pgpass documentation change.

Per Peter.

12 years agoAdd documentation suggestion about adding a comment to the top of
Bruce Momjian [Tue, 6 Sep 2011 21:32:14 +0000 (17:32 -0400)]
Add documentation suggestion about adding a comment to the top of
pgpass.

Backpatch to 9.1.

12 years agoImprove comment about handling of temp tables in shared-inval code.
Tom Lane [Tue, 6 Sep 2011 21:05:48 +0000 (17:05 -0400)]
Improve comment about handling of temp tables in shared-inval code.

12 years agoCorrect ancient logic mistake in assertion
Peter Eisentraut [Tue, 6 Sep 2011 20:05:02 +0000 (23:05 +0300)]
Correct ancient logic mistake in assertion

Found by gcc -Wlogical-op

12 years agoFix plpgsql "PERFORM" markup.
Bruce Momjian [Tue, 6 Sep 2011 19:20:14 +0000 (15:20 -0400)]
Fix plpgsql "PERFORM" markup.

Backpatch to 9.0 and 9.1.

12 years agoAvoid possibly accessing off the end of memory in SJIS2004 conversion.
Tom Lane [Tue, 6 Sep 2011 18:50:28 +0000 (14:50 -0400)]
Avoid possibly accessing off the end of memory in SJIS2004 conversion.

The code in shift_jis_20042euc_jis_2004() would fetch two bytes even when
only one remained in the string.  Since conversion functions aren't
supposed to assume null-terminated input, this poses a small risk of
fetching past the end of memory and incurring SIGSEGV.  No such crash has
been identified in the field, but we've certainly seen the equivalent
happen in other code paths, so patch this one all the way back.

Report and patch by Noah Misch.

12 years agoAvoid possibly accessing off the end of memory in examine_attribute().
Tom Lane [Tue, 6 Sep 2011 18:35:19 +0000 (14:35 -0400)]
Avoid possibly accessing off the end of memory in examine_attribute().

Since the last couple of columns of pg_type are often NULL,
sizeof(FormData_pg_type) can be an overestimate of the actual size of the
tuple data part.  Therefore memcpy'ing that much out of the catalog cache,
as analyze.c was doing, poses a small risk of copying past the end of
memory and incurring SIGSEGV.  No such crash has been identified in the
field, but we've certainly seen the equivalent happen in other code paths,
so patch this one all the way back.

Per valgrind testing by Noah Misch, though this is not his proposed patch.
I chose to use SearchSysCacheCopy1 rather than inventing special-purpose
infrastructure for copying only the minimal part of a pg_type tuple.

12 years agoDocument PERFORM limitation when using WITH queries.
Bruce Momjian [Tue, 6 Sep 2011 17:41:28 +0000 (13:41 -0400)]
Document PERFORM limitation when using WITH queries.

Backpatch to 9.0 and 9.1.

Report from depstein@alliedtesting.com.

12 years agoAdd an "incompatibility" entry to 9.1 release notes about CREATE EXTENSION.
Tom Lane [Tue, 6 Sep 2011 16:36:40 +0000 (12:36 -0400)]
Add an "incompatibility" entry to 9.1 release notes about CREATE EXTENSION.

We've now seen more than one gripe from somebody who didn't get the memo
about how to install contrib modules in 9.1.  Try to make it a little more
prominent that you aren't supposed to call the scripts directly anymore.

12 years agoUpdate type-conversion documentation for long-ago changes.
Tom Lane [Tue, 6 Sep 2011 16:14:51 +0000 (12:14 -0400)]
Update type-conversion documentation for long-ago changes.

This example wasn't updated when we changed the behavior of bpcharlen()
in 8.0, nor when we changed the number of parameters taken by the bpchar()
cast function in 7.3.  Per report from lsliang.

12 years agoProperly document semphore requirements by accounting for worker
Bruce Momjian [Tue, 6 Sep 2011 15:08:32 +0000 (11:08 -0400)]
Properly document semphore requirements by accounting for worker
processes.

Backpatch to 9.1 and 9.0.

Submitted by Anton Yuzhaninov, confirmed by Robert Haas

12 years agoAdd documentation link to strftime supported options.
Bruce Momjian [Tue, 6 Sep 2011 02:58:10 +0000 (22:58 -0400)]
Add documentation link to strftime supported options.

12 years agoAdd C comment about why we send cache invalidation messages for
Bruce Momjian [Tue, 6 Sep 2011 02:08:14 +0000 (22:08 -0400)]
Add C comment about why we send cache invalidation messages for
session-local objects.

12 years agoAdjust translator comment format to xgettext expectations
Alvaro Herrera [Mon, 5 Sep 2011 21:52:49 +0000 (18:52 -0300)]
Adjust translator comment format to xgettext expectations

12 years agoMark some untranslatable messages with errmsg_internal
Alvaro Herrera [Mon, 5 Sep 2011 20:47:18 +0000 (17:47 -0300)]
Mark some untranslatable messages with errmsg_internal

12 years agoImprove "invalid byte sequence for encoding" message
Peter Eisentraut [Mon, 5 Sep 2011 20:36:06 +0000 (23:36 +0300)]
Improve "invalid byte sequence for encoding" message

It used to say

ERROR:  invalid byte sequence for encoding "UTF8": 0xdb24

Change this to

ERROR:  invalid byte sequence for encoding "UTF8": 0xdb 0x24

to make it clear that this is a byte sequence and not a code point.

Also fix the adjacent "character has no equivalent" message that has
the same issue.

12 years agoAdd mention that UTC really means UT1.
Bruce Momjian [Mon, 5 Sep 2011 19:37:58 +0000 (15:37 -0400)]
Add mention that UTC really means UT1.

Backpatch to 9.1.

12 years agoUpdate time zone data files to tzdata release 2011i.
Tom Lane [Mon, 5 Sep 2011 18:46:31 +0000 (14:46 -0400)]
Update time zone data files to tzdata release 2011i.

DST law changes in Canada, Egypt, Russia, Samoa, South Sudan.

12 years agoDocument that contrib/pgtrgm only processes ASCII alphanumeric
Bruce Momjian [Mon, 5 Sep 2011 17:24:45 +0000 (13:24 -0400)]
Document that contrib/pgtrgm only processes ASCII alphanumeric
characters.

Backpatch to 9.0 and 9.1.

12 years agoGuard against using plperl's Makefile without specifying --with-perl.
Tom Lane [Mon, 5 Sep 2011 00:07:34 +0000 (20:07 -0400)]
Guard against using plperl's Makefile without specifying --with-perl.

The $(PERL) macro will be set by configure if it finds perl at all,
but $(perl_privlibexp) isn't configured unless you said --with-perl.
This results in confusing error messages if someone cd's into
src/pl/plperl and tries to build there despite the configure omission,
as reported by Tomas Vondra in bug #6198.  Add simple checks to
provide a more useful report, while not disabling other use of the
makefile such as "make clean".

Back-patch to 9.0, which is as far as the patch applies easily.

12 years agoChange get_variable_numdistinct's API to flag default estimates explicitly.
Tom Lane [Sun, 4 Sep 2011 19:41:49 +0000 (15:41 -0400)]
Change get_variable_numdistinct's API to flag default estimates explicitly.

Formerly, callers tested for DEFAULT_NUM_DISTINCT, which had the problem
that a perfectly solid estimate might be mistaken for a content-free
default.

12 years agoDig down into sub-selects to look for column statistics.
Tom Lane [Sun, 4 Sep 2011 19:13:46 +0000 (15:13 -0400)]
Dig down into sub-selects to look for column statistics.

If a sub-select's output column is a simple Var, recursively look for
statistics applying to that Var, and use them if available.  The need for
this was foreseen ages ago, but we didn't have enough infrastructure to do
it with reasonable speed until just now.

We punt and stick with default estimates if the subquery uses set
operations, GROUP BY, or DISTINCT, since those operations would change the
underlying column statistics (particularly, the relative frequencies of
different values) beyond recognition.  This means that the types of
sub-selects for which this improvement applies are fairly limited, since
most subqueries satisfying those restrictions would have gotten flattened
into the parent query anyway.  But it does help for some cases, such as
subqueries with ORDER BY or LIMIT.

12 years agoCan't print PlannerGlobal's subroots list in outfuncs.
Tom Lane [Sun, 4 Sep 2011 18:43:52 +0000 (14:43 -0400)]
Can't print PlannerGlobal's subroots list in outfuncs.

Since the subroots will surely link back to the same glob struct, this
necessarily leads to infinite recursion.  Doh.  Found while trying to
debug some other code.

12 years agoClean up the #include mess a little.
Tom Lane [Sun, 4 Sep 2011 05:13:16 +0000 (01:13 -0400)]
Clean up the #include mess a little.

walsender.h should depend on xlog.h, not vice versa.  (Actually, the
inclusion was circular until a couple hours ago, which was even sillier;
but Bruce broke it in the expedient rather than logically correct
direction.)  Because of that poor decision, plus blind application of
pgrminclude, we had a situation where half the system was depending on
xlog.h to include such unrelated stuff as array.h and guc.h.  Clean up
the header inclusion, and manually revert a lot of what pgrminclude had
done so things build again.

This episode reinforces my feeling that pgrminclude should not be run
without adult supervision.  Inclusion changes in header files in particular
need to be reviewed with great care.  More generally, it'd be good if we
had a clearer notion of module layering to dictate which headers can sanely
include which others ... but that's a big task for another day.

12 years agoRemove unnecessary and circular #include.
Tom Lane [Sun, 4 Sep 2011 02:14:45 +0000 (22:14 -0400)]
Remove unnecessary and circular #include.

storage/proc.h should not include replication/syncrep.h, especially not
when the latter includes storage/proc.h; but in any case this was a pretty
poor thing from a modular layering standpoint.

12 years agowalsender.h doesn't need xlog.h, per Tom.
Bruce Momjian [Sun, 4 Sep 2011 01:25:00 +0000 (21:25 -0400)]
walsender.h doesn't need xlog.h, per Tom.

12 years agoMove AllowCascadeReplication() define from xlog.h to replication include
Bruce Momjian [Sun, 4 Sep 2011 00:46:19 +0000 (20:46 -0400)]
Move AllowCascadeReplication() define from xlog.h to replication include
file.

Per suggestion from Alvaro.

12 years agoRemove find_lt sgml tool, as it is not needed.
Bruce Momjian [Sat, 3 Sep 2011 23:08:59 +0000 (19:08 -0400)]
Remove find_lt sgml tool, as it is not needed.

Per suggestion from Peter.

12 years agoFix typo in pg_srand48 (srand48 in older branches).
Tom Lane [Sat, 3 Sep 2011 20:17:34 +0000 (16:17 -0400)]
Fix typo in pg_srand48 (srand48 in older branches).

">" should be ">>".  This typo results in failure to use all of the bits
of the provided seed.

This might rise to the level of a security bug if we were relying on
srand48 for any security-critical purposes, but we are not --- in fact,
it's not used at all unless the platform lacks srandom(), which is
improbable.  Even on such a platform the exposure seems minimal.

Reported privately by Andres Freund.

12 years agoRearrange planner to save the whole PlannerInfo (subroot) for a subquery.
Tom Lane [Sat, 3 Sep 2011 19:35:12 +0000 (15:35 -0400)]
Rearrange planner to save the whole PlannerInfo (subroot) for a subquery.

Formerly, set_subquery_pathlist and other creators of plans for subqueries
saved only the rangetable and rowMarks lists from the lower-level
PlannerInfo.  But there's no reason not to remember the whole PlannerInfo,
and indeed this turns out to simplify matters in a number of places.

The immediate reason for doing this was so that the subroot will still be
accessible when we're trying to extract column statistics out of an
already-planned subquery.  But now that I've done it, it seems like a good
code-beautification effort in its own right.

I also chose to get rid of the transient subrtable and subrowmark fields in
SubqueryScan nodes, in favor of having setrefs.c look up the subquery's
RelOptInfo.  That required changing all the APIs in setrefs.c to pass
PlannerInfo not PlannerGlobal, which was a large but quite mechanical
transformation.

One side-effect not foreseen at the beginning is that this finally broke
inheritance_planner's assumption that replanning the same subquery RTE N
times would necessarily give interchangeable results each time.  That
assumption was always pretty risky, but now we really have to make a
separate RTE for each instance so that there's a place to carry the
separate subroots.

12 years agoAdd archive_command example
Peter Eisentraut [Fri, 2 Sep 2011 22:29:09 +0000 (01:29 +0300)]
Add archive_command example

12 years agoWhitespace adjustment for consistency in the file
Peter Eisentraut [Fri, 2 Sep 2011 22:28:05 +0000 (01:28 +0300)]
Whitespace adjustment for consistency in the file

12 years agoTeach ANALYZE to clear pg_class.relhassubclass when appropriate.
Tom Lane [Fri, 2 Sep 2011 18:29:31 +0000 (14:29 -0400)]
Teach ANALYZE to clear pg_class.relhassubclass when appropriate.

In the past, relhassubclass always remained true if a relation had ever had
child relations, even if the last subclass was long gone.  While this had
only marginal performance implications in most cases, it was annoying, and
I'm now considering some planner changes that would raise the cost of a
false positive.  It was previously impractical to fix this because of race
condition concerns.  However, given the recent change that made tablecmds.c
take ShareExclusiveLock on relations that are gaining a child (commit
fbcf4b92aa64d4577bcf25925b055316b978744a), we can now allow ANALYZE to
clear the flag when it's no longer relevant.  There is no additional
locking cost to do so, since ANALYZE takes ShareExclusiveLock anyway.

12 years agoFix brace indentation of commit 63d06ef59156719efd0208c62e764a69611b3f12 to fit Postg...
Michael Meskes [Fri, 2 Sep 2011 07:45:11 +0000 (09:45 +0200)]
Fix brace indentation of commit 63d06ef59156719efd0208c62e764a69611b3f12 to fit PostgreSQL style.

12 years agoImprove method of avoiding fcinfo compile errors.
Bruce Momjian [Thu, 1 Sep 2011 18:15:36 +0000 (14:15 -0400)]
Improve method of avoiding fcinfo compile errors.

Fix pgrminclude C comment marker.

12 years agoRemove spurious comma. Spotted by Tom.
Heikki Linnakangas [Thu, 1 Sep 2011 16:59:09 +0000 (19:59 +0300)]
Remove spurious comma. Spotted by Tom.

12 years agoAdd C comment about needed include.
Bruce Momjian [Thu, 1 Sep 2011 16:53:45 +0000 (12:53 -0400)]
Add C comment about needed include.

12 years agolibpq compiles various pgport files like ecpg does, and needs similar Makefile
Heikki Linnakangas [Thu, 1 Sep 2011 15:58:50 +0000 (18:58 +0300)]
libpq compiles various pgport files like ecpg does, and needs similar Makefile
changes for the win32 setlocale() wrapper I put into ecpg, to make it compile
on MinGW.

12 years agoPut back improperly removed #include.
Tom Lane [Thu, 1 Sep 2011 15:57:09 +0000 (11:57 -0400)]
Put back improperly removed #include.

12 years agoAdd C comment about necessary NetBSD include.
Bruce Momjian [Thu, 1 Sep 2011 15:20:47 +0000 (11:20 -0400)]
Add C comment about necessary NetBSD include.

12 years agoAdd missing hba.h include for NetBSD.
Bruce Momjian [Thu, 1 Sep 2011 14:34:04 +0000 (10:34 -0400)]
Add missing hba.h include for NetBSD.

12 years agoIn SGML we only need to worry about "<", not ">"; update scripts.
Bruce Momjian [Thu, 1 Sep 2011 14:17:04 +0000 (10:17 -0400)]
In SGML we only need to worry about "<", not ">";  update scripts.

12 years agoRemove unnecessary #include references, per pgrminclude script.
Bruce Momjian [Thu, 1 Sep 2011 14:03:22 +0000 (10:03 -0400)]
Remove unnecessary #include references, per pgrminclude script.

12 years agoIn ecpglib restore LC_NUMERIC in case of an error.
Michael Meskes [Thu, 1 Sep 2011 13:27:38 +0000 (15:27 +0200)]
In ecpglib restore LC_NUMERIC in case of an error.

12 years agoMinor improvements to mbregress.sh script.
Robert Haas [Thu, 1 Sep 2011 13:21:10 +0000 (09:21 -0400)]
Minor improvements to mbregress.sh script.

1. Use new dropdb --if-exists option, to avoid alarming the user if
   the database being dropped doesn't already exist.
2. Bail out if createdb fails.
3. exit 1 if the checks fail.
4. Make it executable.

Josh Kupershmidt, with some kibitzing by me.

12 years agoUserspace access vector cache for contrib/sepgsql.
Robert Haas [Thu, 1 Sep 2011 12:37:33 +0000 (08:37 -0400)]
Userspace access vector cache for contrib/sepgsql.

KaiGai Kohei

12 years agoFix "is db labeled test?" in chkselinuxenv script.
Robert Haas [Thu, 1 Sep 2011 12:28:26 +0000 (08:28 -0400)]
Fix "is db labeled test?" in chkselinuxenv script.

Don't test whether the number of labels is numerically equal to zero;
count(*) isn't going return zero anyway, and the current coding blows
up if it returns an empty string or an error.

12 years agoRemove "fmgr.h" include in cube contrib --- caused crash on a Gentoo
Bruce Momjian [Thu, 1 Sep 2011 11:22:01 +0000 (07:22 -0400)]
Remove "fmgr.h" include in cube contrib --- caused crash on a Gentoo
builfarm member.

12 years agoFix MinGW build, broken by my previous patch to add a setlocale() wrapper
Heikki Linnakangas [Thu, 1 Sep 2011 11:02:40 +0000 (14:02 +0300)]
Fix MinGW build, broken by my previous patch to add a setlocale() wrapper
on Windows. ecpglib doesn't link with libpgport, but picks and compiles
the .c files it needs individually. To cope with that, move the setlocale()
wrapper from chklocale.c to a separate setlocale.c file, and include that
in ecpglib.

12 years agosetlocale() on Windows doesn't work correctly if the locale name contains
Heikki Linnakangas [Thu, 1 Sep 2011 08:08:32 +0000 (11:08 +0300)]
setlocale() on Windows doesn't work correctly if the locale name contains
dots. I previously worked around this in initdb, mapping the known
problematic locale names to aliases that work, but Hiroshi Inoue pointed
out that that's not enough because even if you use one of the aliases, like
"Chinese_HKG", setlocale(LC_CTYPE, NULL) returns back the long form, ie.
"Chinese_Hong Kong S.A.R.". When we try to restore an old locale value by
passing that value back to setlocale(), it fails. Note that you are affected
by this bug also if you use one of those short-form names manually, so just
reverting the hack in initdb won't fix it.

To work around that, move the locale name mapping from initdb to a wrapper
around setlocale(), so that the mapping is invoked on every setlocale() call.

Also, add a few checks for failed setlocale() calls in the backend. These
calls shouldn't fail, and if they do there isn't much we can do about it,
but at least you'll get a warning.

Backpatch to 9.1, where the initdb hack was introduced. The Windows bug
affects older versions too if you set locale manually to one of the aliases,
but given the lack of complaints from the field, I'm hesitent to backpatch.

12 years agoMove the line to undefine setlocale() macro on Win32 outside USE_REPL_SNPRINTF
Heikki Linnakangas [Thu, 1 Sep 2011 06:13:37 +0000 (09:13 +0300)]
Move the line to undefine setlocale() macro on Win32 outside USE_REPL_SNPRINTF
ifdef block. It has nothing to do with whether the replacement snprintf
function is used. It caused no live bug, because the replacement snprintf
function is always used on Win32, but it was nevertheless misplaced.

12 years agoFurther repair of eqjoinsel ndistinct-clamping logic.
Tom Lane [Thu, 1 Sep 2011 04:18:28 +0000 (00:18 -0400)]
Further repair of eqjoinsel ndistinct-clamping logic.

Examination of examples provided by Mark Kirkwood and others has convinced
me that actually commit 7f3eba30c9d622d1981b1368f2d79ba0999cdff2 was quite
a few bricks shy of a load.  The useful part of that patch was clamping
ndistinct for the inner side of a semi or anti join, and the reason why
that's needed is that it's the only way that restriction clauses
eliminating rows from the inner relation can affect the estimated size of
the join result.  I had not clearly understood why the clamping was
appropriate, and so mis-extrapolated to conclude that we should clamp
ndistinct for the outer side too, as well as for both sides of regular
joins.  These latter actions were all wrong, and are reverted with this
patch.  In addition, the clamping logic is now made to affect the behavior
of both paths in eqjoinsel_semi, with or without MCV lists to compare.
When we have MCVs, we suppose that the most common values are the ones
that are most likely to survive the decimation resulting from a lower
restriction clause, so we think of the clamping as eliminating non-MCV
values, or potentially even the least-common MCVs for the inner relation.

Back-patch to 8.4, same as previous fixes in this area.

12 years agoFix pg_upgrade to preserve toast relfrozenxids for old 8.3 servers.
Bruce Momjian [Thu, 1 Sep 2011 01:49:58 +0000 (21:49 -0400)]
Fix pg_upgrade to preserve toast relfrozenxids for old 8.3 servers.

This fixes a pg_upgrade bug that could lead to query errors when
clog files are improperly removed.

Backpatch to 8.4, 9.0, 9.1.

12 years agoImprove eqjoinsel's ndistinct clamping to work for multiple levels of join.
Tom Lane [Wed, 31 Aug 2011 20:04:48 +0000 (16:04 -0400)]
Improve eqjoinsel's ndistinct clamping to work for multiple levels of join.

This patch fixes an oversight in my commit
7f3eba30c9d622d1981b1368f2d79ba0999cdff2 of 2008-10-23.  That patch
accounted for baserel restriction clauses that reduced the number of rows
coming out of a table (and hence the number of possibly-distinct values of
a join variable), but not for join restriction clauses that might have been
applied at a lower level of join.  To account for the latter, look up the
sizes of the min_lefthand and min_righthand inputs of the current join,
and clamp with those in the same way as for the base relations.

Noted while investigating a complaint from Ben Chobot, although this in
itself doesn't seem to explain his report.

Back-patch to 8.4; previous versions used different estimation methods
for which this heuristic isn't relevant.

12 years agoThe replication status values in pg_stat_replication was changed to
Heikki Linnakangas [Wed, 31 Aug 2011 09:37:37 +0000 (12:37 +0300)]
The replication status values in pg_stat_replication was changed to
lowercase earlier, but documentation was not updated. Update the docs.

Fujii Masao

12 years agoFix not-backwards-compatible pg_upgrade test for prepared transactions.
Tom Lane [Tue, 30 Aug 2011 21:15:00 +0000 (17:15 -0400)]
Fix not-backwards-compatible pg_upgrade test for prepared transactions.

There's no reason for this test to use the undocumented pg_prepared_xact()
function, when it can use the stable API pg_prepared_xacts instead.
Fixes breakage against 8.3, as reported by Justin Arnold.

12 years agoFix a missed case in code for "moving average" estimate of reltuples.
Tom Lane [Tue, 30 Aug 2011 18:49:45 +0000 (14:49 -0400)]
Fix a missed case in code for "moving average" estimate of reltuples.

It is possible for VACUUM to scan no pages at all, if the visibility map
shows that all pages are all-visible.  In this situation VACUUM has no new
information to report about the relation's tuple density, so it wasn't
changing pg_class.reltuples ... but it updated pg_class.relpages anyway.
That's wrong in general, since there is no evidence to justify changing the
density ratio reltuples/relpages, but it's particularly bad if the previous
state was relpages=reltuples=0, which means "unknown tuple density".
We just replaced "unknown" with "zero".  ANALYZE would eventually recover
from this, but it could take a lot of repetitions of ANALYZE to do so if
the relation size is much larger than the maximum number of pages ANALYZE
will scan, because of the moving-average behavior introduced by commit
b4b6923e03f4d29636a94f6f4cc2f5cf6298b8c8.

The only known situation where we could have relpages=reltuples=0 and yet
the visibility map asserts everything's visible is immediately following
a pg_upgrade.  It might be advisable for pg_upgrade to try to preserve the
relpages/reltuples statistics; but in any case this code is wrong on its
own terms, so fix it.  Per report from Sergey Koposov.

Back-patch to 8.4, where the visibility map was introduced, same as the
previous change.

12 years agoClean up pg_regress --help output
Peter Eisentraut [Tue, 30 Aug 2011 18:25:10 +0000 (21:25 +0300)]
Clean up pg_regress --help output

Put options listing in a less random order, fix capitalization, and
some typos.

12 years agoSome markup cleanup to deconfuse the find_gt_lt tool
Peter Eisentraut [Tue, 30 Aug 2011 17:32:49 +0000 (20:32 +0300)]
Some markup cleanup to deconfuse the find_gt_lt tool

Josh Kupershmidt

12 years agoRepair brain fade in previous commit, per Josh Kupershmidt.
Robert Haas [Tue, 30 Aug 2011 16:49:18 +0000 (12:49 -0400)]
Repair brain fade in previous commit, per Josh Kupershmidt.

12 years agoAdd --if-exists option to dropdb and dropuser.
Robert Haas [Tue, 30 Aug 2011 16:06:40 +0000 (12:06 -0400)]
Add --if-exists option to dropdb and dropuser.

Josh Kupershmidt, with some further editing by me.

12 years agoDetect out of date flex in MSVC builds.
Andrew Dunstan [Tue, 30 Aug 2011 16:06:32 +0000 (12:06 -0400)]
Detect out of date flex in MSVC builds.

Per recent discussion, following a report from Quan Zongliang.
The same logic is used as in pgbison.pl.

12 years agoFix parsing of time string followed by yesterday/today/tomorrow.
Robert Haas [Tue, 30 Aug 2011 15:34:29 +0000 (11:34 -0400)]
Fix parsing of time string followed by yesterday/today/tomorrow.

Previously, 'yesterday 04:00:00'::timestamp didn't do the same thing as
'04:00:00 yesterday'::timestamp, and the return value from the latter
was midnight rather than the specified time.

Dean Rasheed, with some stylistic changes

12 years agoRemove some tabs from README file.
Robert Haas [Tue, 30 Aug 2011 02:25:17 +0000 (22:25 -0400)]
Remove some tabs from README file.

Some of the ASCII art expected 8-space tab stops, and some of it
expected 4-space tab stops.

Per report from YAMAMOTO Takashi.

12 years agoFix concat_ws() to not insert a separator after leading NULL argument(s).
Tom Lane [Mon, 29 Aug 2011 19:20:57 +0000 (15:20 -0400)]
Fix concat_ws() to not insert a separator after leading NULL argument(s).

Per bug #6181 from Itagaki Takahiro.  Also do some marginal code cleanup
and improve error handling.

12 years agoUse a non-locking test in TAS_SPIN() on all IA64 platforms.
Tom Lane [Mon, 29 Aug 2011 17:18:44 +0000 (13:18 -0400)]
Use a non-locking test in TAS_SPIN() on all IA64 platforms.

Per my testing, this works just as well with gcc as it does with HP's
compiler; and there is no reason to think that the effect doesn't occur
with icc, either.

Also, rewrite the header comment about enforcing sequencing around spinlock
operations, per Robert's gripe that it was misleading.

12 years agoImprove spinlock performance for HP-UX, ia64, non-gcc.
Robert Haas [Mon, 29 Aug 2011 14:05:48 +0000 (10:05 -0400)]
Improve spinlock performance for HP-UX, ia64, non-gcc.

At least on this architecture, it's very important to spin on a
non-atomic instruction and only retry the atomic once it appears
that it will succeed.  To fix this, split TAS() into two macros:
TAS(), for trying to grab the lock the first time, and TAS_SPIN(),
for spinning until we get it.  TAS_SPIN() defaults to same as TAS(),
but we can override it when we know there's a better way.

It's likely that some of the other cases in s_lock.h require
similar treatment, but this is the only one we've got conclusive
evidence for at present.

12 years agoActually, all of parallel restore's limitations should be tested earlier.
Tom Lane [Mon, 29 Aug 2011 02:27:48 +0000 (22:27 -0400)]
Actually, all of parallel restore's limitations should be tested earlier.

On closer inspection, whining in restore_toc_entries_parallel is really
much too late for any user-facing error case.  The right place to do it
is at the start of RestoreArchive(), before we've done anything interesting
(suh as trying to DROP all the targets ...)

Back-patch to 8.4, where parallel restore was introduced.

12 years agoBe more user-friendly about unsupported cases for parallel pg_restore.
Tom Lane [Mon, 29 Aug 2011 01:48:58 +0000 (21:48 -0400)]
Be more user-friendly about unsupported cases for parallel pg_restore.

If we are unable to do a parallel restore because the input file is stdin
or is otherwise unseekable, we should complain and fail immediately, not
after having done some of the restore.  Complaining once per thread isn't
so cool either, and the messages should be worded to make it clear this is
an unsupported case not some weird race-condition bug.  Per complaint from
Lonni Friedman.

Back-patch to 8.4, where parallel restore was introduced.

12 years agoInclude $cc_string in the info reported by a configure run.
Tom Lane [Sun, 28 Aug 2011 21:14:52 +0000 (17:14 -0400)]
Include $cc_string in the info reported by a configure run.

Without this, it's not very easy to tell which compiler version a buildfarm
animal is actually using at the moment.

12 years agoModify pgrminclude -v to report include files that can't be compiled on
Bruce Momjian [Sun, 28 Aug 2011 17:04:01 +0000 (13:04 -0400)]
Modify pgrminclude -v to report include files that can't be compiled on
their own.

Avoid compile problems with defines being redefined after the removal of
the #if blocks.

Change script to use shell functions for simplicity.

12 years agoDon't assume that "E" response to NEGOTIATE_SSL_CODE means pre-7.0 server.
Tom Lane [Sat, 27 Aug 2011 20:36:57 +0000 (16:36 -0400)]
Don't assume that "E" response to NEGOTIATE_SSL_CODE means pre-7.0 server.

These days, such a response is far more likely to signify a server-side
problem, such as fork failure.  Reporting "server does not support SSL"
(in sslmode=require) could be quite misleading.  But the results could
be even worse in sslmode=prefer: if the problem was transient and the
next connection attempt succeeds, we'll have silently fallen back to
protocol version 2.0, possibly disabling features the user needs.

Hence, it seems best to just eliminate the assumption that backing off
to non-SSL/2.0 protocol is the way to recover from an "E" response, and
instead treat the server error the same as we would in non-SSL cases.

I tested this change against a pre-7.0 server, and found that there
was a second logic bug in the "prefer" path: the test to decide whether
to make a fallback connection attempt assumed that we must have opened
conn->ssl, which in fact does not happen given an "E" response.  After
fixing that, the code does indeed connect successfully to pre-7.0,
as long as you didn't set sslmode=require.  (If you did, you get
"Unsupported frontend protocol", which isn't completely off base
given the server certainly doesn't support SSL.)

Since there seems no reason to believe that pre-7.0 servers exist anymore
in the wild, back-patch to all supported branches.

12 years agoDocument minimum required version of DocBook XSL stylesheets
Peter Eisentraut [Sat, 27 Aug 2011 20:28:55 +0000 (23:28 +0300)]
Document minimum required version of DocBook XSL stylesheets

12 years agoEnsure we discard unread/unsent data when abandoning a connection attempt.
Tom Lane [Sat, 27 Aug 2011 18:16:14 +0000 (14:16 -0400)]
Ensure we discard unread/unsent data when abandoning a connection attempt.

There are assorted situations wherein PQconnectPoll() will abandon a
connection attempt and try again with different parameters (eg, SSL versus
not SSL).  However, the code forgot to discard any pending data in libpq's
I/O buffers when doing this.  In at least one case (server returns E
message during SSL negotiation), there is unread input data which bollixes
the next connection attempt.  I have not checked to see whether this is
possible in the other cases where we close the socket and retry, but it
seems like a matter of good defensive programming to add explicit
buffer-flushing code to all of them.

This is one of several issues exposed by Daniel Farina's report of
misbehavior after a server-side fork failure.

This has been wrong since forever, so back-patch to all supported branches.

12 years agoAllow more include files to be compiled in their own by adding missing
Bruce Momjian [Sat, 27 Aug 2011 15:05:33 +0000 (11:05 -0400)]
Allow more include files to be compiled in their own by adding missing
include dependencies.

Modify pgcompinclude to skip a common fcinfo error.

12 years agoAdd support for #elif to pgrminclude.
Bruce Momjian [Sat, 27 Aug 2011 13:24:27 +0000 (09:24 -0400)]
Add support for #elif to pgrminclude.

12 years agoImplement the information schema with_hierarchy column
Peter Eisentraut [Sat, 27 Aug 2011 12:03:02 +0000 (15:03 +0300)]
Implement the information schema with_hierarchy column

In PostgreSQL, this is included in the SELECT privilege, so show YES
or NO depending on whether SELECT is granted.