Commit Graph

10023 Commits

Author SHA1 Message Date
Tom Lane 85e2cedf98 Improve bulk-insert performance by keeping the current target buffer pinned
(but not locked, as that would risk deadlocks).  Also, make it work in a small
ring of buffers to avoid having bulk inserts trash the whole buffer arena.

Robert Haas, after an idea of Simon Riggs'.
2008-11-06 20:51:15 +00:00
Heikki Linnakangas 5ae29525d1 The logic in systable_beginscan to translate heap attribute numbers to
index column numbers needs to handle the case where you have more than
one scankey on the same index column. toast_fetch_datum_slice() needs it.
2008-11-06 13:07:08 +00:00
Tom Lane 53b4e469ca This maneuver really requires a comment ... 2008-11-05 20:17:18 +00:00
Andrew Dunstan 0db527c05b change fix for suppress_redundant_updates_trigger() where relation has Oids, to only apply if present Oid is invalid, per second thought from TGL 2008-11-05 19:15:15 +00:00
Andrew Dunstan b65ebc7e8b fix suppress_redundant_updates_trigger() where relation has Oids, per gripe from KaiGai Kohei 2008-11-05 18:49:28 +00:00
Peter Eisentraut 254aecb704 ADD array_ndims function
Author: Robert Haas <robertmhaas@gmail.com>
2008-11-04 14:49:12 +00:00
Peter Eisentraut 9beb9e761b Fix compiler warning about uninitialized variable 2008-11-04 11:04:06 +00:00
Tom Lane 31b15fe8dc Disallow LOCK TABLE outside a transaction block (or function), since this case
almost certainly represents user error.  Per a gripe from Sebastian Böhm
and subsequent discussion.
2008-11-04 00:57:19 +00:00
Tom Lane 99e0996284 Fix compiler warnings (including a seriously bogus elog call); minor
code beautification.
2008-11-04 00:29:39 +00:00
Tom Lane 1a2b41f498 Use bool for a boolean flag. 2008-11-03 23:49:07 +00:00
Peter Eisentraut 84aa797292 Allow uuid_in() to parse a wider variety of variant input formats for the UUID
data type.  This patch takes the approach of allowing an optional hyphen after
each group of four hex digits.

Author: Robert Haas <robertmhaas@gmail.com>
2008-11-03 22:14:40 +00:00
Tom Lane b4eae023bb Clean up the messy semantics (not to mention inefficiency) of PageGetTempPage
by splitting it into three functions with better-defined behaviors.

Zdenek Kotala
2008-11-03 20:47:49 +00:00
Andrew Dunstan f0dae70431 suppress_redundant_updates_trigger function. 2008-11-03 20:17:21 +00:00
Alvaro Herrera 4ff0468371 Fix silly typo in previous commit. 2008-11-03 19:26:07 +00:00
Alvaro Herrera d698bf83d1 Fix TransactionIdSetStatusBit so that it doesn't try to change a transaction
from COMMITTED to SUBCOMMITTED during recovery.  This wasn't previously
possible, but it is now due to the recent changes on clog commit protocol for
subtransactions.

Simon Riggs
2008-11-03 19:24:03 +00:00
Alvaro Herrera 88dd4b0a0d Reduce the acceptable staleness of pgstat data for autovacuum, per the
longstanding note in the source that this patch removes.
2008-11-03 19:03:41 +00:00
Tom Lane b8fab2411d Add pg_typeof() function.
Brendan Jurd
2008-11-03 17:51:13 +00:00
Alvaro Herrera b107299c40 Fix mistakes in comment headers 2008-11-03 15:10:17 +00:00
Tom Lane 3c2313f481 Change the pgstat logic so that the stats collector writes the stats file only
upon requests from backends, rather than on a fixed 500msec cycle.  (There's
still throttling logic to ensure it writes no more often than once per
500msec, though.)  This should result in a significant reduction in stats file
write traffic in typical scenarios where the stats are demanded only
infrequently.

This approach also means that the former difficulty with changing
stats_temp_directory on-the-fly has gone away, so remove the caution about
that as well as the thrashing we did to minimize the trouble window.

In passing, also fix pgstat_report_stat() so that we will send a stats
message if we have function call stats but not table stats to report;
this fixes a bug in the recent patch to support function-call stats.

Martin Pihlak
2008-11-03 01:17:08 +00:00
Tom Lane d7112cfa88 Remove the last vestiges of the MAKE_PTR/MAKE_OFFSET mechanism. We haven't
allowed different processes to have different addresses for the shmem segment
in quite a long time, but there were still a few places left that used the
old coding convention.  Clean them up to reduce confusion and improve the
compiler's ability to detect pointer type mismatches.

Kris Jurka
2008-11-02 21:24:52 +00:00
Tom Lane 902d1cb35f Remove all uses of the deprecated functions heap_formtuple, heap_modifytuple,
and heap_deformtuple in favor of the newer functions heap_form_tuple et al
(which do the same things but use bool control flags instead of arbitrary
char values).  Eliminate the former duplicate coding of these functions,
reducing the deprecated functions to mere wrappers around the newer ones.
We can't get rid of them entirely because add-on modules probably still
contain many instances of the old coding style.

Kris Jurka
2008-11-02 01:45:28 +00:00
Tom Lane df5a99612d Simplify ExecutorRun's API and save some trivial number of cycles by having
it just return void instead of sometimes returning a TupleTableSlot.  SQL
functions don't need that anymore, and noplace else does either.  Eliminating
the return value also means one less hassle for the ExecutorRun hook functions
that will be supported beginning in 8.4.
2008-10-31 21:07:55 +00:00
Heikki Linnakangas e9816533e3 Update FSM on WAL replay. This is a bit limited; the FSM is only updated
on non-full-page-image WAL records, and quite arbitrarily, only if there's
less than 20% free space on the page after the insert/update (not on HOT
updates, though). The 20% cutoff should avoid most of the overhead, when
replaying a bulk insertion, for example, while ensuring that pages that
are full are marked as full in the FSM.

This is mostly to avoid the nasty worst case scenario, where you replay
from a PITR archive, and the FSM information in the base backup is really
out of date. If there was a lot of pages that the outdated FSM claims to
have free space, but don't actually have any, the first unlucky inserter
after the recovery would traverse through all those pages, just to find
out that they're full. We didn't have this problem with the old FSM
implementation, because we simply threw the FSM information away on a
non-clean shutdown.
2008-10-31 19:40:27 +00:00
Tom Lane 9b46abb7c4 Allow SQL-language functions to return the output of an INSERT/UPDATE/DELETE
RETURNING clause, not just a SELECT as formerly.

A side effect of this patch is that when a set-returning SQL function is used
in a FROM clause, performance is improved because the output is collected into
a tuplestore within the function, rather than using the less efficient
value-per-call mechanism.
2008-10-31 19:37:56 +00:00
Michael Meskes cd97f98844 Added missing ';' 2008-10-31 16:36:13 +00:00
Heikki Linnakangas 19c8dc839b Unite ReadBufferWithFork, ReadBufferWithStrategy, and ZeroOrReadBuffer
functions into one ReadBufferExtended function, that takes the strategy
and mode as argument. There's three modes, RBM_NORMAL which is the default
used by plain ReadBuffer(), RBM_ZERO, which replaces ZeroOrReadBuffer, and
a new mode RBM_ZERO_ON_ERROR, which allows callers to read corrupt pages
without throwing an error. The FSM needs the new mode to recover from
corrupt pages, which could happend if we crash after extending an FSM file,
and the new page is "torn".

Add fork number to some error messages in bufmgr.c, that still lacked it.
2008-10-31 15:05:00 +00:00
Heikki Linnakangas 092bc49653 Add support for user-defined I/O conversion casts. 2008-10-31 08:39:22 +00:00
Magnus Hagander 9cc0222680 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:09 +00:00
Tom Lane 2314baef38 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:16 +00:00
Peter Eisentraut 79d306c84a Support for Sun Studio compiler on Linux
This basically takes some build system code that was previously labeled
"Solaris" and ties it to the compiler rather than the operating system.

Author: Julius Stroffek <Julius.Stroffek@Sun.COM>
2008-10-29 16:06:47 +00:00
Peter Eisentraut d083bd7a5a Update on array features support 2008-10-29 11:33:46 +00:00
Peter Eisentraut f7ad874ca8 Since SQL:2003, the array size specification in the SQL ARRAY syntax has
been optional.
2008-10-29 11:24:53 +00:00
Peter Eisentraut 06735e3256 Unicode escapes in strings and identifiers 2008-10-29 08:04:54 +00:00
Tom Lane 05bba3d176 Be more tense about not creating tuplestores with randomAccess = true unless
backwards scan could actually happen.  In particular, pass a flag to
materialize-mode SRFs that tells them whether they need to require random
access.  In passing, also suppress unneeded backward-scan overhead for a
Portal's holdStore tuplestore.  Per my proposal about reducing I/O costs for
tuplestores.
2008-10-29 00:00:39 +00:00
Tom Lane e3e3d2a789 Extend ExecMakeFunctionResult() to support set-returning functions that return
via a tuplestore instead of value-per-call.  Refactor a few things to reduce
ensuing code duplication with nodeFunctionscan.c.  This represents the
reasonably noncontroversial part of my proposed patch to switch SQL functions
over to returning tuplestores.  For the moment, SQL functions still do things
the old way.  However, this change enables PL SRFs to be called in targetlists
(observe changes in plperl regression results).
2008-10-28 22:02:06 +00:00
Tom Lane a80a12247a Change WorkTableScan to not support backward scan. The apparent support
didn't actually work, because nodeRecursiveunion.c creates the underlying
tuplestore with backward scan disabled; which is a decision that we shouldn't
reverse because of performance cost.  We could imagine adding signaling from
WorkTableScan to RecursiveUnion about whether backward scan is needed ...
but in practice it'd be a waste of effort, because there simply isn't any
current or plausible future scenario where WorkTableScan would be called on
to scan backward.  So just dike out the code that claims to support it.
2008-10-28 17:13:51 +00:00
Tom Lane d26bf23f34 Arrange to squeeze out the MINIMAL_TUPLE_PADDING in the tuple representation
written to temp files by tuplesort.c and tuplestore.c.  This saves 2 bytes per
row for 32-bit machines, and 6 bytes per row for 64-bit machines, which seems
worth the slight additional uglification of the tuple read/write routines.
2008-10-28 15:51:03 +00:00
Peter Eisentraut 8ecd535169 Add WITH [NO] DATA clause to CREATE TABLE AS, per SQL.
Also, since WITH is now a reserved word, simplify the token merging code to
only deal with WITH_TIME.

by Tom Lane and myself
2008-10-28 14:09:45 +00:00
Magnus Hagander 53a5026b5c Remove support for (insecure) crypt authentication.
This breaks compatibility with pre-7.2 versions.
2008-10-28 12:10:44 +00:00
Alvaro Herrera ba4eb01554 Downgrade can't-happen error reports to elog(). 2008-10-27 22:15:05 +00:00
Alvaro Herrera c9d1efda96 No need for extra code to log freezing zero tuples. Callers already check that
they are freezing a nonzero amount anyway.
2008-10-27 21:50:12 +00:00
Magnus Hagander e98ca4d383 Make hba parsing error messages more specific. 2008-10-27 20:04:45 +00:00
Tom Lane b0169bb124 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:22 +00:00
Peter Eisentraut 0fec77ae88 SQL:2008 syntax CURRENT_CATALOG, CURRENT_SCHEMA, SET CATALOG, SET SCHEMA. 2008-10-27 09:37:47 +00:00
Peter Eisentraut 5163b94e6f Allow EXPLAIN on CREATE TABLE AS. 2008-10-27 08:47:14 +00:00
Peter Eisentraut e5da8e15ba Feature list update 2008-10-27 07:26:24 +00:00
Tom Lane 0aed62fea9 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:25 +00:00
Tom Lane aa0fb53016 Be a little smarter about qual handling for semi-joins: a qual that mentions
only the outer side can be pushed down rather than having to be evaluated
at the join.
2008-10-25 19:51:32 +00:00
Tom Lane ddbe8dca08 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:09 +00:00
Tom Lane 312b1a983f Reduce the memory footprint of large pending-trigger-event lists, as per my
recent proposal.  In typical cases, we now need 12 bytes per insert or delete
event and 16 bytes per update event; previously we needed 40 bytes per
event on 32-bit hardware and 80 bytes per event on 64-bit hardware.  Even
in the worst case usage pattern with a large number of distinct triggers being
fired in one query, usage is at most 32 bytes per event.  It seems to be a
bit faster than the old code as well, due to reduction of palloc overhead.

This commit doesn't address the TODO item of allowing the event list to spill
to disk; rather it's trying to stave off the need for that.  However, it
probably makes that task a bit easier by reducing the data structure's
dependency on pointers.  It would now be practical to dump an event list to
disk by "chunks" instead of individual events.
2008-10-24 23:42:35 +00:00