Tom Lane [Mon, 11 Apr 2005 19:51:32 +0000 (19:51 +0000)]
Fix interaction between materializing holdable cursors and firing
deferred triggers: either one can create more work for the other,
so we have to loop till it's all gone. Per example from andrew@supernews.
Add a regression test to help spot trouble in this area in future.
Tom Lane [Mon, 11 Apr 2005 15:59:47 +0000 (15:59 +0000)]
PersistHoldablePortal must establish the correct value for ActiveSnapshot
while completing execution of the cursor's query. Otherwise we get wrong
answers or even crashes from non-volatile functions called by the query.
Per report from andrew@supernews.
Tom Lane [Sun, 10 Apr 2005 20:57:45 +0000 (20:57 +0000)]
Make constant-folding produce sane output for COALESCE(NULL,NULL),
that is a plain NULL and not a COALESCE with no inputs. Fixes crash
reported by Michael Williamson.
Tom Lane [Sun, 10 Apr 2005 18:04:31 +0000 (18:04 +0000)]
SQL functions returning pass-by-reference types were copying the results
into the wrong memory context, resulting in a query-lifespan memory leak.
Bug is new in 8.0, I believe. Per report from Rae Stiening.
Tom Lane [Sun, 3 Apr 2005 00:02:03 +0000 (00:02 +0000)]
Put back code mistakenly removed from copy of postmaster's
daemonize routine, namely forcing stdin/stdout/stderr to point
to /dev/null. Per Karl Denninger.
Tom Lane [Fri, 1 Apr 2005 20:32:09 +0000 (20:32 +0000)]
Second try at making examine_variable and friends behave sanely in
cases with binary-compatible relabeling. My first try was implicitly
assuming that all operators scalarineqsel is used for have binary-
compatible datatypes on both sides ... which is very wrong of course.
Per report from Michael Fuhr.
Tom Lane [Thu, 31 Mar 2005 23:21:09 +0000 (23:21 +0000)]
Flush any remaining statistics counts out to the collector at process
exit. Without this, operations triggered during backend exit (such as
temp table deletions) won't be counted ... which given heavy usage of
temp tables can lead to pg_autovacuum falling way behind on the need
to vacuum pg_class and pg_attribute. Per reports from Steve Crawford
and others.
Tom Lane [Sat, 26 Mar 2005 20:55:58 +0000 (20:55 +0000)]
Fix a pair of related issues with estimation of inequalities that involve
binary-compatible relabeling of one or both operands. examine_variable
should avoid stripping RelabelType from non-variable expressions, so that
they will continue to have the correct type; and convert_to_scalar should
just use that type and ignore the other input type. This isn't perfect
but it beats failing entirely. Per example from Michael Fuhr.
Tom Lane [Sat, 26 Mar 2005 00:41:45 +0000 (00:41 +0000)]
Prevent to_char(interval) from dumping core on month-related formats
when a zero-month interval is given. Per discussion with Karel.
Also, some desultory const-labeling of constant tables. More could be
done along that line.
Tom Lane [Fri, 25 Mar 2005 22:51:42 +0000 (22:51 +0000)]
Remove lazy_update_relstats; go back to having VACUUM just record the
actual number of unremoved tuples as pg_class.reltuples. The idea of
trying to estimate a steady state condition still seems attractive, but
this particular implementation crashed and burned ...
Tom Lane [Fri, 25 Mar 2005 18:04:47 +0000 (18:04 +0000)]
Fix two bugs in change_owner_recurse_to_sequences: it was grabbing an
overly strong lock on pg_depend, and it wasn't closing the rel when done.
The latter bug was masked by the ResourceOwner code, which is something
that should be changed.
Tom Lane [Fri, 25 Mar 2005 00:35:20 +0000 (00:35 +0000)]
Kerberos fixes from Magnus Hagander --- in theory Kerberos 5 auth
should work on Windows now. Also, rename set_noblock to pg_set_noblock;
since it is included in libpq, the former name polluted application
namespace.
Tom Lane [Thu, 24 Mar 2005 21:50:52 +0000 (21:50 +0000)]
array_map can't use the fn_extra field of the provided fcinfo struct as
its private storage, because that belongs to the function that it is
supposed to call. Per report from Ezequiel Tolnay.
Bruce Momjian [Thu, 24 Mar 2005 19:33:40 +0000 (19:33 +0000)]
Force PG client applications to link to non-shared libpgport before
linking to libpq. This insulates applications from changes in libpq's
usage of libpgport functions.
Tom Lane [Thu, 24 Mar 2005 19:15:11 +0000 (19:15 +0000)]
Tweak planner to use a minimum size estimate of 10 pages for a
never-yet-vacuumed relation. This restores the pre-8.0 behavior of
avoiding seqscans during initial data loading, while still allowing
reasonable optimization after a table has been vacuumed. Several
regression test cases revert to 7.4-like behavior, which is probably
a good sign. Per gripes from Keith Browne and others.
Tom Lane [Thu, 24 Mar 2005 17:22:44 +0000 (17:22 +0000)]
Adjust plpython to convert \r\n and \r to \n in Python scripts,
per recent discussion concluding that this is the Right Thing. Add
regression test check for this behavior. Michael Fuhr
Bruce Momjian [Thu, 24 Mar 2005 04:37:07 +0000 (04:37 +0000)]
Change Win32 O_SYNC method to O_DSYNC because that is what the method
currently does. This is now the default Win32 wal sync method because
we perfer o_datasync to fsync.
Also, change Win32 fsync to a new wal sync method called
fsync_writethrough because that is the behavior of _commit, which is
what is used for fsync on Win32.
Tom Lane [Wed, 23 Mar 2005 19:06:54 +0000 (19:06 +0000)]
Previous "64-bit fix" for intagg didn't actually work. This is already
fixed properly in CVS tip, but we need a band-aid for back branches.
Per report from Ron Mayer.
Tom Lane [Wed, 23 Mar 2005 00:04:25 +0000 (00:04 +0000)]
WAL must log CREATE and DROP DATABASE operations *without* using any
explicit paths, so that the log can be replayed in a data directory
with a different absolute path than the original had. To avoid forcing
initdb in the 8.0 branch, continue to accept the old WAL log record
types; they will never again be generated however, and the code can be
dropped after the next forced initdb. Per report from Oleg Bartunov.
We still need to think about what it really means to WAL-log CREATE
TABLESPACE commands: we more or less have to put the absolute path
into those, but how to replay in a different context??
Tom Lane [Mon, 21 Mar 2005 16:29:31 +0000 (16:29 +0000)]
Fix quote_ident to use quote_identifier rather than its own, not quite
up-to-speed logic; in particular this will cause it to quote names that
match keywords. Remove unnecessary multibyte cruft from quote_literal
(all backend-internal encodings are 8-bit-safe).
Tom Lane [Fri, 18 Mar 2005 03:49:19 +0000 (03:49 +0000)]
Treat EPERM as a non-error case when checking to see if old postmaster
is still alive. This improves our odds of not getting fooled by an
unrelated process when checking a stale lock file. Other checks already
in place, plus one newly added in checkDataDir(), ensure that we cannot
attempt to usurp the place of a postmaster belonging to a different userid,
so there is no need to error out. Add comments indicating the importance
of these other checks.
Tom Lane [Sat, 12 Mar 2005 21:12:05 +0000 (21:12 +0000)]
Fix ALTER DATABASE RENAME to allow the operation if user is a superuser
who for some reason isn't marked usecreatedb. Per report from Alexander
Pravking. Also fix sloppy coding in have_createdb_privilege().
Neil Conway [Sat, 12 Mar 2005 06:54:31 +0000 (06:54 +0000)]
Some builds (depends on crypto engine support?) of OpenSSL
0.9.7x have EVP_DigestFinal function which which clears all of
EVP_MD_CTX. This makes pgcrypto crash in functions which
re-use one digest context several times: hmac() and crypt()
with md5 algorithm.
Following patch fixes it by carring the digest info around
EVP_DigestFinal and re-initializing cipher.
Tom Lane [Sat, 12 Mar 2005 01:55:15 +0000 (01:55 +0000)]
Fix problem with infinite recursion between write_syslogger_file and
elog if the former has trouble writing its file. Code review for
Magnus' patch to redirect stderr to syslog on Windows (Bruce's version
seems right, but did some minor prettification).
Tom Lane [Thu, 3 Mar 2005 16:47:43 +0000 (16:47 +0000)]
Replace ARC cache management algorithm with the similar but slightly
simpler 2Q algorithm, to avoid possible problems with the pending patent
on ARC. Testing so far suggests that there is little if any performance
loss from doing this.
Note that this patch is going into the 8.0 branch only; a much more
extensive revision is planned for HEAD.
Tom Lane [Tue, 1 Mar 2005 21:15:10 +0000 (21:15 +0000)]
Release proclock immediately in RemoveFromWaitQueue() if it represents
no held locks. This maintains the invariant that proclocks are present
only for procs that are holding or awaiting a lock; when this is not
true, LockRelease will fail. Per report from Stephen Clouse.
Tom Lane [Tue, 1 Mar 2005 01:40:39 +0000 (01:40 +0000)]
Adjust OR indexscan logic to not generate redundant condition-free OR
indexscans involving partial indexes. These would always be dominated
by a simple indexscan on such an index, so there's no point in considering
them. Fixes overoptimism in a patch I applied last October.
Tom Lane [Tue, 1 Mar 2005 00:25:45 +0000 (00:25 +0000)]
Revert the logic for expanding AND/OR conditions in pred_test() to what
it was in 7.4, and add some comments explaining why it has to be this way.
I broke it for OR'd index predicates in a fit of code cleanup last summer.
Per example from Sergey Koshcheyev.
Tom Lane [Sat, 19 Feb 2005 23:16:27 +0000 (23:16 +0000)]
New arrangement to always let the bgwriter do checkpoints broke
CHECKPOINT and some other commands in the context of a standalone
backend. Allow a standalone backend to do its own checkpoints.
Tom Lane [Sat, 19 Feb 2005 19:33:23 +0000 (19:33 +0000)]
Ensure that the resolved datatype of any unknown Param is propagated
into the sub-SELECT targetlist when it appears in the context
INSERT INTO foo SELECT $1 ... Per report from Abhijit Menon-Sen.
Tom Lane [Thu, 10 Feb 2005 20:36:49 +0000 (20:36 +0000)]
Fix SPI cursor support to allow scanning the results of utility commands
that return tuples (such as EXPLAIN). Per gripe from Michael Fuhr.
Side effect: fix an old bug that unintentionally disabled backward scans
for all SPI-created cursors.
Neil Conway [Wed, 9 Feb 2005 23:27:24 +0000 (23:27 +0000)]
ALTER TABLE ADD COLUMN exhibits a significant memory leak when adding a
column with a default expression. In that situation, we need to rewrite
the heap relation. To evaluate the new default expression, we use
ExecEvalExpr(); however, this can allocate memory in the current memory
context, and ATRewriteTable() does not switch out of the active portal's
heap memory context. The end result is a rather large memory leak (on
the order of gigabytes for a reasonably sized table).
This patch changes ATRewriteTable() to switch to the per-tuple memory
context before beginning the per-tuple loop. It also removes an explicit
heap_freetuple() in the loop, since that is no longer needed.
In an unrelated change, I noticed the code was scanning through the
attributes of the new tuple descriptor for each tuple of the old table.
I changed this to use precomputation, which should slightly speed up
the loop.
Neil Conway [Mon, 7 Feb 2005 03:52:22 +0000 (03:52 +0000)]
Prevent 4 more buffer overruns in the PL/PgSQL parser. This is just a
minimally-invasive fix for stable branches; a cleaner fix will be
committed to HEAD soon.
Tom Lane [Sun, 6 Feb 2005 20:19:24 +0000 (20:19 +0000)]
Repair CLUSTER failure after ALTER TABLE SET WITHOUT OIDS. Turns out
there are corner cases involving dropping toasted columns in which the
previous coding would fail, too: the new version of the table might not
have any TOAST table, but we'd still propagate possibly-wide values of
dropped columns forward.
Tom Lane [Thu, 3 Feb 2005 23:39:21 +0000 (23:39 +0000)]
Fix minor thinko in logic to set dump order when dumping from a pre-7.3
database: aggregates should be dumped in the same pass as operators,
not in the same pass as functions.
Tom Lane [Thu, 3 Feb 2005 23:30:12 +0000 (23:30 +0000)]
Ensure that all details of the ARC algorithm are hidden within freelist.c.
This refactoring does not change any algorithms or data structures, just
remove visibility of the ARC datastructures from other source files.
Tom Lane [Wed, 2 Feb 2005 21:49:49 +0000 (21:49 +0000)]
Adjust constant-folding of CASE expressions so that the simple comparison
form of CASE (eg, CASE 0 WHEN 1 THEN ...) can be constant-folded as it
was in 7.4. Also, avoid constant-folding result expressions that are
certainly unreachable --- the former coding was a bit cavalier about this
and could generate unexpected results for all-constant CASE expressions.
Add regression test cases. Per report from Vlad Marchenko.