26478 Commits

Author SHA1 Message Date
Tom Lane
c0118c11a8 Fix dblink and tablefunc to not return with the wrong CurrentMemoryContext.
Per buildfarm results.
2008-11-30 23:24:01 +00:00
Tom Lane
37e4c7219b Remove inappropriate memory context switch in shutdown_MultiFuncCall().
This was a thinko introduced in a patch from last February; it results
in memory leakage if an SRF is shut down before the actual end of query,
because subsequent code will be running in a longer-lived context than
it's expecting to be.
2008-11-30 18:49:42 +00:00
Tom Lane
b9e8986d1b Back-patch change to make DISCARD ALL release advisory locks.
Per discussion.
2008-11-27 00:34:49 +00:00
Michael Meskes
0b1953868e Replaced strchrnul by strchr. 2008-11-26 15:37:01 +00:00
Michael Meskes
c892504fa6 When creating a varchar struct name braces must be discarded. 2008-11-26 13:19:34 +00:00
Tom Lane
fb2a0a450b information_schema.key_column_usage.position_in_unique_constraint was
misdocumented as not being implemented.  In reality it has worked since
the release of 8.2.
2008-11-25 20:47:49 +00:00
Peter Eisentraut
05798c9275 Fix crash of xmlconcat(NULL)
backpatch from 8.4devel
2008-11-15 20:53:40 +00:00
Tom Lane
b608b24245 Prevent synchronous scan during GIN index build, because GIN is optimized
for inserting tuples in increasing TID order.  It's not clear whether this
fully explains Ivan Sergio Borgonovo's complaint, but simple testing
confirms that a scan that doesn't start at block 0 can slow GIN build by
a factor of three or four.

Backpatch to 8.3.  Sync scan didn't exist before that.
2008-11-13 17:42:19 +00:00
Peter Eisentraut
940c412d7f Since the xmlagg section was moved, "below" is no longer accurate. 2008-11-13 14:37:32 +00:00
Tom Lane
a7baa6deed In predtest.c, install a limit on the number of branches we will process in
AND, OR, or equivalent clauses: if there are too many (more than 100) just
exit without proving anything.  This ensures that we don't spend O(N^2) time
trying (and most likely failing) to prove anything about very long IN lists
and similar cases.

Also, install a couple of CHECK_FOR_INTERRUPTS calls to ensure that a long
proof attempt can be interrupted.

Per gripe from Sergey Konoplev.

Back-patch the whole patch to 8.2 and just the CHECK_FOR_INTERRUPTS addition
to 8.1.  (The rest of the patch doesn't apply cleanly, and since 8.1 doesn't
show the complained-of behavior anyway, it doesn't seem necessary to work
hard on it.)
2008-11-12 23:08:42 +00:00
Heikki Linnakangas
5b9c854dae Fix off-by-one error in autovacuum shmem struct sizing. This could lead to
autovacuum worker sending SIGUSR1 signal to wrong process, per Zou Yong's
report.

Backpatch to 8.3.
2008-11-12 10:10:43 +00:00
Andrew Dunstan
9ac53e7978 Detect and error out on inability to get proper linkage information required for plperl, usually due to absence of perl ExtUtils::Embed module. Backpatch as far as 8.1. 2008-11-12 00:00:29 +00:00
Magnus Hagander
24e1815bb0 Mention the tup_fetched column in pg_stat_database.
Greg Sabino Mullane
2008-11-11 20:06:25 +00:00
Tom Lane
213647b158 Get rid of adjust_appendrel_attr_needed(), which has been broken ever since
we extended the appendrel mechanism to support UNION ALL optimization.  The
reason nobody noticed was that we are not actually using attr_needed data for
appendrel children; hence it seems more reasonable to rip it out than fix it.
Back-patch to 8.2 because an Assert failure is possible in corner cases.
Per examination of an example from Jim Nasby.

In HEAD, also get rid of AppendRelInfo.col_mappings, which is quite inadequate
to represent UNION ALL situations; depend entirely on translated_vars instead.
2008-11-11 18:13:44 +00:00
Tom Lane
47925b83cb Fix bugs in sqlchar_to_unicode and unicode_to_sqlchar: both were measuring
the length of a UTF8 character with pg_mblen (wrong if DB encoding isn't
UTF8), and the latter was blithely assuming that a static buffer would somehow
revert to all zeroes for each use.
2008-11-10 18:02:27 +00:00
Tom Lane
af9b481653 Fix old bug in contrib/sslinfo: X509_NAME_to_text freed the BIO_s_mem buffer
it was using too soon.  In a situation where pg_do_encoding_conversion is
a no-op, this led to garbage data returned.

In HEAD, also modify the code that's ensuring null termination to make it
a tad more obvious what's happening.
2008-11-10 14:57:46 +00:00
Bruce Momjian
d0d2d74ce7 Document that 'sslmode' is ignored for Unix domain socket communication;
backpatch to 8.3.X.
2008-11-04 22:36:12 +00:00
Marc G. Fournier
a06dedfc5e commit for 8.3.5 REL8_3_5 2008-10-31 02:38:34 +00:00
Tom Lane
7e23bd31d1 Update back-branch release notes. 2008-10-30 22:22:41 +00:00
Peter Eisentraut
b7c5f65df5 Translation updates 2008-10-30 21:30:20 +00:00
Magnus Hagander
3a0b0e8260 Revert previous patch to put the shared memory segment on win32
in the Global\ namespace, because it caused permission errors on
a lot of platforms.

We need to come up with something better for 8.4, but for now
revert to the pre-8.3.4 behaviour.
2008-10-30 17:04:11 +00:00
Tom Lane
f6dc2786ab Update time zone data files to tzdata release 2008i (DST law changes in
Argentina, Brazil, Mauritius, Syria).
2008-10-30 13:17:02 +00:00
Peter Eisentraut
2926e1bcfb Missing space in error message 2008-10-30 12:27:42 +00:00
Peter Eisentraut
a1bbfa78b4 Improve new message 2008-10-30 08:51:13 +00:00
Tom Lane
b56cdf3b85 Fix recoveryLastXTime logic so that it actually does what one would expect.
Per gripe from Kevin Grittner.  Backpatch to 8.3, where the bug was introduced.
2008-10-30 04:06:25 +00:00
Tom Lane
4b2315f493 Install a more robust solution for the problem of infinite error-processing
recursion when we are unable to convert a localized error message to the
client's encoding.  We've been over this ground before, but as reported by
Ibrar Ahmed, it still didn't work in the case of conversion failures for
the conversion-failure message itself :-(.  Fix by installing a "circuit
breaker" that disables attempts to localize this message once we get into
recursion trouble.

Patch all supported branches, because it is in fact broken in all of them;
though I had to add some missing translations to the older branches in
order to expose the failure in the particular test case I was using.
2008-10-27 19:37:29 +00:00
Tom Lane
1d18f940a3 Better solution to the IN-list issue: instead of having an arbitrary cutoff,
treat Var and non-Var IN-list items differently.  Only non-Var items are
candidates to go into an ANY(ARRAY) construct --- we put all Vars as separate
OR conditions on the grounds that that leaves more scope for optimization.
Per suggestion from Robert Haas.
2008-10-26 02:46:30 +00:00
Tom Lane
6571729d54 Add a heuristic to transformAExprIn() to make it prefer expanding "x IN (list)"
into an OR of equality comparisons, rather than x = ANY(ARRAY[...]), when there
are Vars in the right-hand side.  This avoids a performance regression compared
to pre-8.2 releases, in cases where the OR form can be optimized into scans
of multiple indexes.  Limit the possible downside by preferring this form only
when the list isn't very long (I set the cutoff at 32 elements, which is a
bit arbitrary but in the right ballpark).  Per discussion with Jim Nasby.

In passing, also make it try the OR form if it cannot select a common type
for the array elements; we've seen a complaint or two about how the OR form
worked for such cases and ARRAY doesn't.
2008-10-25 17:19:17 +00:00
Tom Lane
d4a1e5b0a3 Fix an old bug in after-trigger handling: AfterTriggerEndQuery took the
address of afterTriggers->query_stack[afterTriggers->query_depth] and hung
onto it through all its firings of triggers.  However, if a trigger causes
sufficiently many nested query executions, query_stack will get repalloc'd
bigger, leaving AfterTriggerEndQuery --- and hence afterTriggerInvokeEvents
--- using a stale pointer.

So far as I can find, the only consequence of this error is to stomp on a
couple of words of already-freed memory; which would lead to a failure only if
that chunk had already gotten re-allocated for something else.  So it's hard
to exhibit a simple failure case, but this is surely a bug.

I noticed this while working on my recent patch to reduce pending-trigger
space usage.  The present patch is mighty ugly, because it requires making
afterTriggerInvokeEvents know about all the possible event lists it might get
called on.  Fortunately, this is only needed in back branches because CVS HEAD
avoids the problem in a different way: afterTriggerInvokeEvents only touches
the passed AfterTriggerEventList pointer once at startup.  Back branches are
stable enough that wiring in knowledge of all possible call usages doesn't
seem like a killer problem.

Back-patch to 8.0.  7.4's trigger code is completely different and doesn't
seem to have the problem (it doesn't even use repalloc).
2008-10-25 03:32:44 +00:00
Magnus Hagander
13a7d7f3cc Fix memory leak when using gsslib parameter in libpq connections 2008-10-23 16:17:22 +00:00
Peter Eisentraut
3690d7d5cf On second thought, let's not get involved in correcting the feature list
in 8.3.  The list is quite outdated, and fixing it up would require more
effort.  Plus, we don't want diverging information schema contents.
2008-10-23 11:12:56 +00:00
Teodor Sigaev
666aad267b Fix GiST's killing tuple: GISTScanOpaque->curpos wasn't
correctly set. As result, killtuple() marks as dead
wrong tuple on page. Bug was introduced by me while fixing
possible duplicates during GiST index scan.
2008-10-22 12:54:25 +00:00
Peter Eisentraut
6a112282b9 Small correction SQL feature table 2008-10-17 23:21:09 +00:00
Teodor Sigaev
81a2651f6a Fix small bug in headline generation.
Patch from Sushant Sinha <sushant354@gmail.com>
http://archives.postgresql.org/pgsql-hackers/2008-07/msg00785.php
2008-10-17 17:32:59 +00:00
Teodor Sigaev
2cae6fe717 During repeated rescan of GiST index it's possible that scan key
is NULL but SK_SEARCHNULL is not set. Add checking IS NULL of keys
to set during key initialization. If key is NULL and SK_SEARCHNULL is not
set then nothnig can be satisfied.
With assert-enabled compilation that causes coredump.

Bug was introduced in 8.3 by support of IS NULL index scan.
2008-10-17 17:02:42 +00:00
Neil Conway
6a6f47d00a Fix a small memory leak in ExecReScanAgg() in the hashed aggregation case.
In the previous coding, the list of columns that needed to be hashed on
was allocated in the per-query context, but we reallocated every time
the Agg node was rescanned. Since this information doesn't change over
a rescan, just construct the list of columns once during ExecInitAgg().
2008-10-16 19:25:58 +00:00
Tom Lane
b9053b1e6a Fix SPI_getvalue and SPI_getbinval to range-check the given attribute number
according to the TupleDesc's natts, not the number of physical columns in the
tuple.  The previous coding would do the wrong thing in cases where natts is
different from the tuple's column count: either incorrectly report error when
it should just treat the column as null, or actually crash due to indexing off
the end of the TupleDesc's attribute array.  (The second case is probably not
possible in modern PG versions, due to more careful handling of inheritance
cases than we once had.  But it's still a clear lack of robustness here.)

The incorrect error indication is ignored by all callers within the core PG
distribution, so this bug has no symptoms visible within the core code, but
it might well be an issue for add-on packages.  So patch all the way back.
2008-10-16 13:23:28 +00:00
Tom Lane
7494c0e0d4 Fix COPY documentation to not imply that HEADER can be used outside CSV mode.
Per gripe from Bill Thoen.
2008-10-10 21:46:43 +00:00
Tom Lane
794ccacd5f Fix omission of DiscardStmt in GetCommandLogLevel, per report from Hubert
Depesz Lubaczewski.  In HEAD, also move a couple of other cases to make the
code ordering match up with ProcessUtility.
2008-10-10 13:48:12 +00:00
Michael Meskes
603972f3e0 Optional arguments should be optional. 2008-10-10 12:20:06 +00:00
Tom Lane
a4f5d8a51e Fix overly tense optimization of PLpgSQL_func_hashkey: we must represent
the isTrigger state explicitly, not rely on nonzero-ness of trigrelOid
to indicate trigger-hood, because trigrelOid will be left zero when compiling
for validation.  The (useless) function hash entry built by the validator
was able to match an ordinary non-trigger call later in the same session,
thereby bypassing the check that is supposed to prevent such a call.
Per report from Alvaro.

It might be worth suppressing the useless hash entry altogether, but
that's a bigger change than I want to consider back-patching.

Back-patch to 8.0.  7.4 doesn't have the problem because it doesn't
have validation mode.
2008-10-09 16:35:13 +00:00
Tom Lane
5b61c9a812 Fix crash in bytea-to-XML mapping when the source value is toasted.
Report and fix by Michael McMaster.  Some minor code beautification by me,
also avoid memory leaks in the special-case paths.
2008-10-09 15:49:10 +00:00
Heikki Linnakangas
95f3c355bd Force a checkpoint in CREATE DATABASE before starting to copy the files,
to process any pending unlinks for the source database.

Before, if you dropped a relation in the template database just before
CREATE DATABASE, and a checkpoint happened during copydir(), the checkpoint
might delete a file that we're just about to copy, causing lstat() in
copydir() to fail with ENOENT.

Backpatch to 8.3, where the pending unlinks were introduced.

Per report by Matthew Wakeling and analysis by Tom Lane.
2008-10-09 10:34:22 +00:00
Heikki Linnakangas
3c66048adb When a relation is moved to another tablespace, we can't assume that we can
use the old relfilenode in the new tablespace. There might be another relation
in the new tablespace with the same relfilenode, so we must generate a fresh
relfilenode in the new tablespace.

The 8.3 patch to let deleted relation files linger as zero-length files until
the next checkpoint made this more obvious: moving a relation from one table
space another, and then back again, caused a collision with the lingering
file.

Back-patch to 8.1. The issue is present in 8.0 as well, but it doesn't seem
worth fixing there, because we didn't have protection from OID collisions
after OID wraparound before 8.1.

Report by Guillaume Lelarge.
2008-10-07 11:15:48 +00:00
Tom Lane
260fc8d5c7 Fix improper display of fractional seconds in interval values
when using --enable-integer-datetimes and a non-ISO datestyle.

Ron Mayer
2008-10-02 13:47:44 +00:00
Magnus Hagander
3862493ad3 Link libpq with libgssapi if configure finds it, as
required by at least NetBSD.

Markus Schaaf
2008-10-01 15:35:34 +00:00
Tom Lane
57a2091013 Recent patches to pg_ctl broke "pg_ctl restart" for the case where no
command-line options had been given to the postmaster; and just plain
broke it altogether in 8.1 and 8.0.  Per report from KaiGai Kohei.
2008-09-30 13:14:07 +00:00
Andrew Dunstan
ef6f342644 Compare escaped chars case insensitively for ILIKE - per gripe from TGL. 2008-09-27 16:57:43 +00:00
Tom Lane
7ef0097998 Fix more problems with rewriter failing to set Query.hasSubLinks when inserting
a SubLink expression into a rule query.  We missed cases where the original
query contained a sub-SELECT in a function in FROM, a multi-row VALUES list,
or a RETURNING list.  Per bug #4434 from Dean Rasheed and subsequent
investigation.

Back-patch to 8.1; older releases don't have the issue because they didn't
try to be smart about setting hasSubLinks only when needed.
2008-09-24 16:52:53 +00:00
Magnus Hagander
7898ff7185 Make sure pg_control is opened in binary mode, to deal
with situtations when the file contains an EOF maker
(0x1A) on Windows.

ITAGAKI Takahiro
2008-09-24 08:59:46 +00:00