1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-25 21:42:33 +03:00

21611 Commits

Author SHA1 Message Date
Neil Conway
81dbda0792 Per a bug report from Theo Schlossnagle, plperl_return_next() leaks
memory in the executor's per-query memory context. It also inefficient:
it invokes get_call_result_type() and TupleDescGetAttInMetadata() for
every call to return_next, rather than invoking them once (per PL/Perl
function call) and memoizing the result.

This patch makes the following changes:

- refactor the code to include all the "per PL/Perl function call" data
inside a single struct, "current_call_data". This means we don't need to
save and restore N pointers for every recursive call into PL/Perl, we
can just save and restore one.

- lookup the return type metadata needed by plperl_return_next() once,
and then stash it in "current_call_data", so as to avoid doing the
lookup for every call to return_next.

- create a temporary memory context in which to evaluate the return
type's input functions. This memory context is reset for each call to
return_next.

The patch appears to fix the memory leak, and substantially reduces
the overhead imposed by return_next.
2006-01-28 03:28:19 +00:00
Tom Lane
108a2e51c9 Fix display of whole-row Var appearing at the top level of a SELECT list.
While we normally prefer the notation "foo.*" for a whole-row Var, that does
not work at SELECT top level, because in that context the parser will assume
that what is wanted is to expand the "*" into a list of separate target
columns, yielding behavior different from a whole-row Var.  We have to emit
just "foo" instead in that context.  Per report from Sokolov Yura.
2006-01-26 17:08:26 +00:00
Tom Lane
f31a58481c Remove unnecessary PQconsumeInput call from PQputCopyData; it's redundant
because pqSendSome will absorb input data anytime it'd be forced to block.
Avoiding a kernel call per PQputCopyData call helps COPY speed materially.

Alon Goldshuv
2006-01-25 20:44:49 +00:00
Tom Lane
b34608fbdd Fix unportable usage of socklen_t: should use ACCEPT_TYPE_ARG3 macro
provided by configure, instead.  Per bug #2205.
2006-01-24 16:38:50 +00:00
Tom Lane
16582d3834 Repair longstanding bug in slru/clog logic: it is possible for two backends
to try to create a log segment file concurrently, but the code erroneously
specified O_EXCL to open(), resulting in a needless failure.  Before 7.4,
it was even a PANIC condition :-(.  Correct code is actually simpler than
what we had, because we can just say O_CREAT to start with and not need a
second open() call.  I believe this accounts for several recent reports of
hard-to-reproduce "could not create file ...: File exists" errors in both
pg_clog and pg_subtrans.
2006-01-21 04:38:27 +00:00
Tom Lane
4977c2b31b Replace bitwise looping with bytewise looping in hemdistsign and
sizebitvec of tsearch2, as well as identical code in several other
contrib modules.  This provided about a 20X speedup in building a
large tsearch2 index ... didn't try to measure its effects for other
operations.  Thanks to Stephan Vollmer for providing a test case.
2006-01-20 22:46:40 +00:00
Bruce Momjian
4a651c9705 Update EXPLAIN wording for GEQO usage. 2006-01-20 16:42:02 +00:00
Tom Lane
517056bd08 Fix thinko in autovacuum's test to skip temp tables: want to skip any
temp table not only our own process' tables.  It's not real important
since vacuum.c will skip temp tables anyway, but might as well make the
code do what it claims to do.
2006-01-20 15:17:13 +00:00
Bruce Momjian
936433ba53 Doc patch that adds an example of a correllated UPDATE.
David Fetter
2006-01-19 23:09:46 +00:00
Bruce Momjian
b148ce8a4a Clarify STABLE function documentation to highlight how such functions
can be optimized.
2006-01-19 22:52:20 +00:00
Tom Lane
337cc41236 Add some test scaffolding to allow cache-flush stress testing (and I do
mean stress ... system is orders of magnitude slower with this enabled).
2006-01-19 21:49:30 +00:00
Bruce Momjian
36cdb24f31 Remove $(DESTDIR) from the pgxs BE_DLLLIBS= -L path for AIX and Darwin. 2006-01-19 21:19:15 +00:00
Bruce Momjian
128cd9df38 Remove $(DESTDIR) from the pgxs BE_DLLLIBS= -L path. 2006-01-19 20:45:34 +00:00
Tom Lane
ab2cd7266b Avoid crashing if relcache flush occurs while trying to load data into an
index's support-function cache (in index_getprocinfo).  Since none of that
data can change for an index that's in active use, it seems sufficient to
treat all open indexes the same way we were treating "nailed" system indexes
--- that is, just re-read the pg_class row and leave the rest of the relcache
entry strictly alone.  The pg_class re-read might not be strictly necessary
either, but since the reltablespace and relfilenode can change in normal
operation it seems safest to do it.  (We don't support changing any of the
other info about an index at all, at the moment.)

Back-patch as far as 8.0.  It might be possible to adapt the patch to 7.4,
but it would take more work than I care to expend for such a low-probability
problem.  7.3 is out of luck for sure.
2006-01-19 20:28:48 +00:00
Bruce Momjian
b5dc7165fe Fix pgxs -L library path specification for Win32 and Cygwin, was /bin,
now /lib.
2006-01-19 20:01:01 +00:00
Tom Lane
7618330c6d It turns out that TablespaceCreateDbspace fails badly if a relcache flush
occurs when it tries to heap_open pg_tablespace.  When control returns to
smgrcreate, that routine will be holding a dangling pointer to a closed
SMgrRelation, resulting in mayhem.  This is of course a consequence of
the violation of proper module layering inherent in having smgr.c call
a tablespace command routine, but the simplest fix seems to be to change
the locking mechanism.  There's no real need for TablespaceCreateDbspace
to touch pg_tablespace at all --- it's only opening it as a way of locking
against a parallel DROP TABLESPACE command.  A much better answer is to
create a special-purpose LWLock to interlock these two operations.
This drops TablespaceCreateDbspace quite a few layers down the food chain
and makes it something reasonably safe for smgr to call.
2006-01-19 04:45:47 +00:00
Tom Lane
49a263011a Fix a tiny memory leak (one List header) in RelationCacheInvalidate().
This is utterly insignificant in normal operation, but it becomes a
problem during cache inval stress testing.  The original coding in fact
had no leak --- the 8.0 List rewrite created the issue.  I wonder whether
list_concat should pfree the discarded header?
2006-01-19 00:27:27 +00:00
Bruce Momjian
2e2c4f424f Clarify use of btree indexes for ILIKE and ~*. 2006-01-18 22:26:01 +00:00
Tom Lane
0bfd90ff32 Modify pgstats code to reduce performance penalties from oversized stats data
files: avoid creating stats hashtable entries for tables that aren't being
touched except by vacuum/analyze, ensure that entries for dropped tables are
removed promptly, and tweak the data layout to avoid storing useless struct
padding.  Also improve the performance of pgstat_vacuum_tabstat(), and make
sure that autovacuum invokes it exactly once per autovac cycle rather than
multiple times or not at all.  This should cure recent complaints about 8.1
showing much higher stats I/O volume than was seen in 8.0.  It'd still be a
good idea to revisit the design with an eye to not re-writing the entire
stats dataset every half second ... but that would be too much to backpatch,
I fear.
2006-01-18 20:35:16 +00:00
Tom Lane
9e72b3c2c5 Fix fsync code to test whether F_FULLFSYNC is available, instead of
assuming it always is on Darwin.  Per report from Neil Brandt.
2006-01-17 23:52:50 +00:00
Tom Lane
7b3d9367b4 Repair problems with the result of lookup_rowtype_tupdesc() possibly being
discarded by cache flush while still in use.  This is a minimal patch that
just copies the tupdesc anywhere it could be needed across a flush.  Applied
to back branches only; Neil Conway is working on a better long-term solution
for HEAD.
2006-01-17 17:33:23 +00:00
Neil Conway
afe91cae6c When using GCC on AMD64 and PPC, ECPGget_variable() takes a va_list *, not
a va_list. Christof Petig's previous patch made this change, but neglected
to update ecpglib/descriptor.c, resulting in a compiler warning (and a
likely runtime crash) on AMD64 and PPC.
2006-01-15 22:47:10 +00:00
Peter Eisentraut
5032245807 Fix pg_ctl crash on "unregister" when a data directory is not specified.
by Magnus Hagander
2006-01-14 16:16:08 +00:00
Neil Conway
5dc3d1b0be We neglected to apply domain constraints on UNKNOWN parameters to
prepared statements, per report from David Wheeler.
2006-01-12 22:29:11 +00:00
Tom Lane
a933c4e59e Repair "Halloween problem" in EvalPlanQual: a tuple that's been inserted by
our own command (or more generally, xmin = our xact and cmin >= current
command ID) should not be seen as good.  Else we may try to update rows
we already updated.  This error was inserted last August while fixing the
even bigger problem that the old coding wouldn't see *any* tuples inserted
by our own transaction as good.  Per report from Euler Taveira de Oliveira.
2006-01-12 21:49:07 +00:00
Tom Lane
e2c60a2cfe Use a more bulletproof test for whether finite() and isinf() are present.
It seems that recent gcc versions can optimize away calls to these functions
even when the functions do not exist on the platform, resulting in a bogus
positive result.  Avoid this by using a non-constant argument and ensuring
that the function result is not simply discarded.  Per report from
François Laupretre.
2006-01-12 19:23:41 +00:00
Tom Lane
34b0ac6ada Remove extraneous backslash from 'fixseq.sql' example --- mea culpa
certainly.  Per report from George Woodring.
2006-01-12 18:09:42 +00:00
Tom Lane
db55a807de Improve error messages for missing-FROM-entry cases, as per recent discussion. 2006-01-10 22:00:07 +00:00
Neil Conway
e838df6ff8 In PLy_function_build_args(), the code loops repeatedly, constructing
one argument at a time and then inserting the argument into a Python
list via PyList_SetItem(). This "steals" the reference to the argument:
that is, the reference to the new list member is now held by the Python
list itself. This works fine, except if an elog occurs. This causes the
function's PG_CATCH() block to be invoked, which decrements the
reference counts on both the current argument and the list of arguments.
If the elog happens to occur during the second or subsequent iteration
of the loop, the reference count on the current argument will be
decremented twice.

The fix is simple: set the local pointer to the current argument to NULL
immediately after adding it to the argument list. This ensures that the
Py_XDECREF() in the PG_CATCH() block doesn't double-decrement.
2006-01-10 00:33:30 +00:00
Tom Lane
d3934a3f38 Fix pg_dump to add the required OPERATOR() decoration to schema-qualified
operator names.  This is needed when dumping operator definitions that have
COMMUTATOR (or similar) links to operators in other schemas.
Apparently Daniel Whitter is the first person ever to try this :-(
2006-01-09 21:16:25 +00:00
Andrew Dunstan
ed47146f1e Stop perl from hijacking stdio and other stuff on Windows. 2006-01-08 15:50:00 +00:00
Tom Lane
e1926aa91e Add RelationOpenSmgr() calls to ensure rd_smgr is valid when we try to
use it.  While it normally has been opened earlier during btree index
build, testing shows that it's possible for the link to be closed again
if an sinval reset occurs while the index is being built.
2006-01-07 22:45:53 +00:00
Tom Lane
c66f4ec569 During CatCacheRemoveCList, we must now remove any members that are
dead and have become unreferenced.  Before 8.1, such members were left
for AtEOXact_CatCache() to clean up, but now AtEOXact_CatCache isn't
supposed to have anything to do.  In an assert-enabled build this bug
leads to an assertion failure at transaction end, but in a non-assert
build the dead member is effectively just a small memory leak.
Per report from Jeremy Drake.
2006-01-07 21:16:44 +00:00
Tom Lane
4b1f09d5bd Fix failure to apply domain constraints to a NULL constant that's added to
an INSERT target list during rule rewriting.  Per report from John Supplee.
2006-01-06 20:11:18 +00:00
Tom Lane
68f4ed462a Release-note updates and copy editing. REL8_1_2 2006-01-06 03:00:06 +00:00
Tom Lane
c628930966 Fix Windows-only postmaster code to reject a connection request and continue,
rather than elog(FATAL), when there is no more room in ShmemBackendArray.
This is a security issue since too many connection requests arriving close
together could cause the postmaster to shut down, resulting in denial of
service.  Reported by Yoshiyuki Asaba, fixed by Magnus Hagander.
2006-01-06 02:58:32 +00:00
Tom Lane
9395f4911a Convert Assert checking for empty page into a regular test and elog.
The consequences of overwriting a non-empty page are bad enough that
we should not omit this test in production builds.
2006-01-06 00:15:58 +00:00
Tom Lane
cf3c9c14c3 Fix ReadBuffer() to correctly handle the case where it's trying to extend
the relation but it finds a pre-existing valid buffer.  The buffer does not
correspond to any page known to the kernel, so we *must* do smgrextend to
ensure that the space becomes allocated.  The 7.x branches all do this
correctly, but the corner case got lost somewhere during 8.0 bufmgr rewrites.
(My fault no doubt :-( ... I think I assumed that such a buffer must be
not-BM_VALID, which is not so.)
2006-01-06 00:04:26 +00:00
Bruce Momjian
ffc7186004 New pgcrypto item wording. 2006-01-05 15:19:52 +00:00
Bruce Momjian
61180e80d4 Wording improvements. 2006-01-05 15:13:26 +00:00
Bruce Momjian
045de2d865 Improve markup. 2006-01-05 14:54:07 +00:00
Peter Eisentraut
3e62f08e9a Translation update 2006-01-05 09:32:12 +00:00
Bruce Momjian
e0f1f8ad0b Update release notes for 8.1.X, 8.0.X, 7.4.X, and 7.3.X. 2006-01-05 05:16:03 +00:00
Bruce Momjian
f54a68d24a Stamp release 8.1.2. 2006-01-05 04:02:26 +00:00
Tom Lane
e9bb12d5ab Arrange to set the LC_XXX environment variables to match our locale setup.
Back-patch of previous fix in HEAD for plperl-vs-locale issue.
2006-01-05 00:54:51 +00:00
Tom Lane
f336613438 Fix another case in which autovacuum would fail while analyzing
expressional indexes.  Per report from Brian Hirt.
2006-01-04 19:16:32 +00:00
Tom Lane
f5b50af291 There is a signedness bug in Openwall gen_salt code that pgcrypto uses.
This makes the salt space for md5 and xdes algorithms a lot smaller than
it should be.

Marko Kreen
2006-01-03 23:46:38 +00:00
Joe Conway
17903a7375 When the remote query result has a different number of columns
than the local query specifies (e.g. in the FROM clause),
throw an ERROR (instead of crashing). Fix for bug #2129 reported
by Akio Iwaasa.
2006-01-03 23:46:32 +00:00
Tom Lane
54b84d4838 Fix incorrect treatment of RL_PROMPT_START_IGNORE/RL_PROMPT_END_IGNORE,
per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=343616 via Martin Pitt.
2006-01-03 23:32:34 +00:00
Tom Lane
495be39266 Add checks to verify that a plpgsql function returning a rowtype is actually
returning the rowtype it's supposed to return.  Per reports from David Niblett
and Michael Fuhr.
2006-01-03 22:48:21 +00:00