Commit Graph

26315 Commits

Author SHA1 Message Date
Andrew Dunstan
990344b31b Add multi-line flag to regex that needs it. Backpatch to 8.2. Fix from Andreas Zeugswetter 2008-04-15 16:23:21 +00:00
Tom Lane
0b7afedb5c A quick try at un-breaking the Cygwin build. Whether it needs the
pgwin32_safestat remains to be determined, but in any case the current
code is not tolerable.
2008-04-11 23:59:49 +00:00
Tom Lane
56295419f2 Fix several datatype input functions that were allowing unused bytes in their
results to contain uninitialized, unpredictable values.  While this was okay
as far as the datatypes themselves were concerned, it's a problem for the
parser because occurrences of the "same" literal might not be recognized as
equal by datumIsEqual (and hence not by equal()).  It seems sufficient to fix
this in the input functions since the only critical use of equal() is in the
parser's comparisons of ORDER BY and DISTINCT expressions.
Per a trouble report from Marc Cousin.

Patch all the way back.  Interestingly, array_in did not have the bug before
8.2, which may explain why the issue went unnoticed for so long.
2008-04-11 22:52:17 +00:00
Magnus Hagander
36146d4d54 Create wrapper pgwin32_safestat() and redefine stat() to it
on win32, because the stat() function in the runtime cannot
be trusted to always update the st_size field.

Per report and research by Sergey Zubkovsky.
2008-04-10 16:59:10 +00:00
Michael Meskes
4fcff62991 Fixed bug in PGTYPEStimestamp_sub that used pointers instead of the values to substract. 2008-04-10 10:46:22 +00:00
Tom Lane
1c3722f280 Fix tsvector_update_trigger() to be domain-friendly: it needs to allow all
the columns it works with to be domains over the expected type, not just
exactly the expected type.  In passing, fix ts_stat() the same way.
Per report from Markus Wollny.
2008-04-08 18:20:34 +00:00
Tom Lane
5e8146c7cf Defend against JOINs having more than 32K columns altogether. We cannot
currently support this because we must be able to build Vars referencing
join columns, and varattno is only 16 bits wide.  Perhaps this should be
improved in future, but considering that it never came up before, I'm not
sure the problem is worth much effort.  Per bug #4070 from Marcello
Ceschia.

The problem seems largely academic in 8.0 and 7.4, because they have
(different) O(N^2) performance issues with such wide joins, but
back-patch all the way anyway.
2008-04-05 01:58:28 +00:00
Tom Lane
affdd52d5f Teach ANALYZE to distinguish dead and in-doubt tuples, which it formerly
classed all as "dead"; also get it to count DEAD item pointers as dead rows,
instead of ignoring them as before.  Also improve matters so that tuples
previously inserted or deleted by our own transaction are handled nicely:
the stats collector's live-tuple and dead-tuple counts will end up correct
after our transaction ends, regardless of whether we end in commit or abort.

While there's more work that could be done to improve the counting of in-doubt
tuples in both VACUUM and ANALYZE, this commit is enough to alleviate some
known bad behaviors in 8.3; and the other stuff that's been discussed seems
like research projects anyway.

Pavan Deolasee and Tom Lane
2008-04-03 16:27:32 +00:00
Peter Eisentraut
db6c80de8b Remove -C from rsync call, because it omits directories named "core". 2008-04-03 09:51:53 +00:00
Tom Lane
ab2071b53d Revert my bad decision of about a year ago to make PortalDefineQuery
responsible for copying the query string into the new Portal.  Such copying
is unnecessary in the common code path through exec_simple_query, and in
this case it can be enormously expensive because the string might contain
a large number of individual commands; we were copying the entire, long
string for each command, resulting in O(N^2) behavior for N commands.
(This is the cause of bug #4079.)  A second problem with it is that
PortalDefineQuery really can't risk error, because if it elog's before
having set up the Portal, we will leak the plancache refcount that the
caller is trying to hand off to the portal.  So go back to the design in
which the caller is responsible for making sure everything is copied into
the portal if necessary.
2008-04-02 18:32:00 +00:00
Tom Lane
e3a47483a2 Fix an oversight I made in a cleanup patch over a year ago:
eval_const_expressions needs to be passed the PlannerInfo ("root") structure,
because in some cases we want it to substitute values for Param nodes.
(So "constant" is not so constant as all that ...)  This mistake partially
disabled optimization of unnamed extended-Query statements in 8.3: in
particular the LIKE-to-indexscan optimization would never be applied if the
LIKE pattern was passed as a parameter, and constraint exclusion depending
on a parameter value didn't work either.
2008-04-01 00:48:44 +00:00
Tom Lane
f82277c80d Apply my original fix for Taiki Yamaguchi's bug report about DISTINCT MAX().
Add some regression tests for plausible failures in this area.
2008-03-31 16:59:33 +00:00
Tom Lane
793c583508 Fix a number of places that were making file-type tests infelicitously.
The places that did, eg,
	(statbuf.st_mode & S_IFMT) == S_IFDIR
were correct, but there is no good reason not to use S_ISDIR() instead,
especially when that's what the other 90% of our code does.  The places
that did, eg,
	(statbuf.st_mode & S_IFDIR)
were flat out *wrong* and would fail in various platform-specific ways,
eg a symlink could be mistaken for a regular file on most Unixen.

The actual impact of this is probably small, since the problem cases
seem to always involve symlinks or sockets, which are unlikely to be
found in the directories that PG code might be scanning.  But it's
clearly trouble waiting to happen, so patch all the way back anyway.
(There seem to be no occurrences of the mistake in 7.4.)
2008-03-31 01:32:01 +00:00
Tom Lane
92c3a80043 Revert my erroneous fix for Taiki Yamaguchi's DISTINCT MAX() bug.
Whatever we do about that, this isn't the path to the solution.
2008-03-29 00:15:37 +00:00
Tom Lane
707867e9fd When we have successfully optimized a MIN or MAX aggregate into an indexscan,
the query result must be exactly one row (since we don't do this when there's
any GROUP BY).  Therefore any ORDER BY or DISTINCT attached to the query is
useless and can be dropped.  Aside from saving useless cycles, this protects
us against problems with matching the hacked-up tlist entries to sort clauses,
as seen in a bug report from Taiki Yamaguchi.  We might need to work harder
if we ever try to optimize grouped queries with this approach, but this
solution will do for now.
2008-03-27 19:06:23 +00:00
Magnus Hagander
1c0e618e17 Include \password in the psql help.
While at it, change the order of the documented options to be
alphabetically again.
2008-03-26 15:52:36 +00:00
Tom Lane
a07375e39a Fix core dump in contrib/xml2's xpath_table() when the input query returns
a NULL value.  Per bug #4058.
2008-03-26 01:19:11 +00:00
Michael Meskes
e5fab267c5 added ECPGget_PGconn to exports.txt 2008-03-25 12:45:33 +00:00
Tom Lane
6644be6ece When a relation has been proven empty by constraint exclusion, propagate that
knowledge up through any joins it participates in.  We were doing that already
in some special cases but not in the general case.  Also, defend against zero
row estimates for the input relations in cost_mergejoin --- this fix may have
eliminated the only scenario in which that can happen, but be safe.  Per
report from Alex Solovey.
2008-03-24 21:53:12 +00:00
Tom Lane
63995f01ed Fix various infelicities that have snuck into usage of errdetail() and
friends.  Avoid double translation of some messages, ensure other messages
are exposed for translation (and make them follow the style guidelines),
avoid unsafe passing of an unpredictable message text as a format string.
2008-03-24 19:12:58 +00:00
Michael Meskes
4866b529f3 Corrected version number. 2008-03-21 16:10:10 +00:00
Michael Meskes
94a710563e Added ECPGget_PGconn() function to ecpglib, courtesy of Mike Aubury.
Bumped library version to 6.1.
2008-03-20 16:30:14 +00:00
Michael Meskes
6a78d754d0 Changed statement escaping to not escape continuation line markers.
Bumped precompiler patchlevel.
2008-03-20 16:04:52 +00:00
Heikki Linnakangas
59c4fc5a80 Add the missing cyrillic "Yo" characters ('e' and 'E' with two dots) to the
ISO_8859-5 <-> MULE_INTERNAL conversion tables.

This was discovered when trying to convert a string containing those characters
from ISO_8859-5 to Windows-1251, because we use MULE_INTERNAL/KOI8R as an
intermediate encoding between those two.

While the missing "Yo" was just an omission in the conversion tables, there are
a few other characters like the "Numero" sign ("No" as a single character) that
exists in all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but
not in KOI8R. Added comments about that.

Patch by Sergey Burladyan. Back-patch to 7.4.
2008-03-20 10:35:45 +00:00
Tom Lane
7c5fcbf48f Fix regexp substring matching (substring(string from pattern)) for the corner
case where there is a match to the pattern overall but the user has specified
a parenthesized subexpression and that subexpression hasn't got a match.
An example is substring('foo' from 'foo(bar)?').  This should return NULL,
since (bar) isn't matched, but it was mistakenly returning the whole-pattern
match instead (ie, 'foo').  Per bug #4044 from Rui Martins.

This has been broken since the beginning; patch in all supported versions.
The old behavior was sufficiently inconsistent that it's impossible to believe
anyone is depending on it.
2008-03-19 02:40:43 +00:00
Magnus Hagander
9217c262fe cvsweb lives on anoncvs.postgresql.org these days. 2008-03-18 16:05:09 +00:00
Magnus Hagander
b4a2dae6df Wiki page about cvs now lives in the main wiki, the one
on developer.postgresql.org is going away.
2008-03-18 16:02:29 +00:00
Tom Lane
2059a5a1bc Fix inappropriately-timed memory context switch in autovacuum_do_vac_analyze.
This accidentally failed to fail before 8.3, because the context we were
switching back to was long-lived anyway; but it sure looks risky as can be
now.  Well spotted by Pavan Deolasee.
2008-03-14 23:49:33 +00:00
Alvaro Herrera
e5ecea0d73 Fix duplicate word, per Guillaume Lelarge. 2008-03-14 17:28:24 +00:00
Alvaro Herrera
9c37a4810e Fix vacuum so that autovacuum is really not cancelled when doing an emergency
job (i.e. to prevent Xid wraparound problems.)  Bug reported by ITAGAKI
Takahiro in 20080314103837.63D3.52131E4D@oss.ntt.co.jp, though I didn't use his
patch.
2008-03-14 17:26:01 +00:00
Peter Eisentraut
c666edb5eb Translation updates 2008-03-14 04:46:30 +00:00
Marc G. Fournier
fdd23cd69e update configure for 8.3.1 prior to tag 2008-03-14 03:23:22 +00:00
Tom Lane
eb66892ed6 Stamp version 8.3.1, except for configure.in/configure. 2008-03-13 23:57:34 +00:00
Tom Lane
8de5f596f4 Update release notes for 8.3.1 and 8.2.7 releases. 2008-03-13 23:47:59 +00:00
Tom Lane
1cf866a8df Update to tzdata 2008a distribution (Chilean DST law change). 2008-03-13 19:21:49 +00:00
Tom Lane
96e420a6ec Fix varstr_cmp's special case for UTF8 encoding on Windows so that strings
that are reported as "equal" by wcscoll() are checked to see if they really
are bitwise equal, and are sorted per strcmp() if not.  We made this happen
a couple of years ago in the regular code path, but it unaccountably got
left out of the Windows/UTF8 case (probably brain fade on my part at the
time).  As in the prior set of changes, affected users may need to reindex
indexes on textual columns.

Backpatch as far as 8.2, which is the oldest release we are still supporting
on Windows.
2008-03-13 18:32:02 +00:00
Tom Lane
8efc13140e Fix heap_page_prune's problem with failing to send cache invalidation
messages if the calling transaction aborts later on.  Collapsing out line
pointer redirects is a done deal as soon as we complete the page update,
so syscache *must* be notified even if the VACUUM FULL as a whole doesn't
complete.  To fix, add some functionality to inval.c to allow the pending
inval messages to be sent immediately while heap_page_prune is still
running.  The implementation is a bit chintzy: it will only work in the
context of VACUUM FULL.  But that's all we need now, and it can always be
extended later if needed.  Per my trouble report of a week ago.
2008-03-13 18:00:39 +00:00
Tom Lane
1dd56fdae4 Fix pg_plan_queries() to restore the previous setting of ActiveSnapshot
(probably NULL) before exiting.  Up to now it's just left the variable as it
set it, which means that after we're done processing the current client
message, ActiveSnapshot is probably pointing at garbage (because this function
is typically run in MessageContext which will get reset).  There doesn't seem
to have been any code path in which that mattered before 8.3, but now the
plancache module might try to use the stale value if the next client message
is a Bind for a prepared statement that is in need of replanning.  Per report
from Alex Hunsaker.
2008-03-12 23:58:35 +00:00
Tom Lane
d2ab94dac2 Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
pg_listener modifications commanded by LISTEN and UNLISTEN until the end
of the current transaction.  This allows us to hold the ExclusiveLock on
pg_listener until after commit, with no greater risk of deadlock than there
was before.  Aside from fixing the race condition, this gets rid of a
truly ugly kludge that was there before, namely having to ignore
HeapTupleBeingUpdated failures during NOTIFY.  There is a small potential
incompatibility, which is that if a transaction issues LISTEN or UNLISTEN
and then looks into pg_listener before committing, it won't see any resulting
row insertion or deletion, where before it would have.  It seems unlikely
that anyone would be depending on that, though.

This patch also disallows LISTEN and UNLISTEN inside a prepared transaction.
That case had some pretty undesirable properties already, such as possibly
allowing pg_listener entries to be made for PIDs no longer present, so
disallowing it seems like a better idea than trying to maintain the behavior.
2008-03-12 20:11:54 +00:00
Bruce Momjian
32aaf48022 Add to documentation:
+         Setting <varname>statement_timeout</> in
+         <filename>postgresql.conf</> is not recommended because it
+         affects all sessions.

Backpatch to 8.3.X.
2008-03-11 16:59:09 +00:00
Bruce Momjian
ff0e149c49 Back out doc addition that statement_timeout affects autovacuum. 2008-03-11 15:49:52 +00:00
Bruce Momjian
3d5bc6dc93 Document that statement_timeout is not recommended in postgresql.conf
because it affects all sessions, including autovacuum.
2008-03-11 15:39:33 +00:00
Tom Lane
899b9c3e04 Use -fwrapv in CFLAGS if we are using a version of gcc that accepts this flag.
This prevents compiler optimizations that assume overflow won't occur, which
breaks numerous overflow tests that we need to have working.  It is known
that gcc 4.3 causes problems and possible that 4.1 does.  Per my proposal
of some time ago and a recent report from Kris Jurka.

Backpatch as far as 8.0, which is as far as the patch conveniently goes.
7.x was pretty short of overflow tests anyway, so it may not matter there,
even assuming that anyone cares whether 7.x builds on recent gcc.
2008-03-10 21:50:23 +00:00
Teodor Sigaev
d19d35431b Revert changes of CompareTSQ: it affects existing btree indexes. 2008-03-09 10:42:48 +00:00
Tom Lane
f647ed438a Refactor heap_page_prune so that instead of changing item states on-the-fly,
it accumulates the set of changes to be made and then applies them.  It had
to accumulate the set of changes anyway to prepare a WAL record for the
pruning action, so this isn't an enormous change; the only new complexity is
to not doubly mark tuples that are visited twice in the scan.  The main
advantage is that we can substantially reduce the scope of the critical
section in which the changes are applied, thus avoiding PANIC in foreseeable
cases like running out of memory in inval.c.  A nice secondary advantage is
that it is now far clearer that WAL replay will actually do the same thing
that the original pruning did.

This commit doesn't do anything about the open problem that
CacheInvalidateHeapTuple doesn't have the right semantics for a CTID change
caused by collapsing out a redirect pointer.  But whatever we do about that,
it'll be a good idea to not do it inside a critical section.
2008-03-08 21:58:07 +00:00
Tom Lane
bdffbddd06 Change hashscan.c to keep its list of active hash index scans in
TopMemoryContext, rather than scattered through executor per-query contexts.
This poses no danger of memory leak since the ResourceOwner mechanism
guarantees release of no-longer-needed items.  It is needed because the
per-query context might already be released by the time we try to clean up
the hash scan list.  Report by ykhuang, diagnosis by Heikki.

Back-patch to 8.0, where the ResourceOwner-based cleanup was introduced.
The given test case does not fail before 8.2, probably because we rearranged
transaction abort processing somehow; but this coding is undoubtedly risky
so I'll patch 8.0 and 8.1 anyway.
2008-03-07 15:59:09 +00:00
Teodor Sigaev
b7a2ab5b6e Fix memory arrangement of tsquery after removing stop words. It causes
a unused memory holes in tsquery.

Per report by Richard Huxton <dev@archonet.com>.

It was working well because in fact tsquery->size is not used for any
kind of operation except comparing tsqueries. To prevent requirement
of renew all stored tsquery optimization in CompareTSQ is removed.
2008-03-07 15:29:27 +00:00
Bruce Momjian
ffeae03742 Clearify PITR doc wording. 2008-03-07 01:46:50 +00:00
Bruce Momjian
1c945db3d1 Document that enabling asserts can _significantly_ slow down the server.
Back patch to 8.3.X.
2008-03-06 21:37:40 +00:00
Bruce Momjian
4cf827e8d0 Move client encoding libpq function docs into libpq doc section, and
just reference them from the localization doc section.

Backpatch to 8.3.X.
2008-03-06 15:38:02 +00:00