Tom Lane [Thu, 16 Sep 2004 16:58:44 +0000 (16:58 +0000)]
Restructure subtransaction handling to reduce resource consumption,
as per recent discussions. Invent SubTransactionIds that are managed like
CommandIds (ie, counter is reset at start of each top transaction), and
use these instead of TransactionIds to keep track of subtransaction status
in those modules that need it. This means that a subtransaction does not
need an XID unless it actually inserts/modifies rows in the database.
Accordingly, don't assign it an XID nor take a lock on the XID until it
tries to do that. This saves a lot of overhead for subtransactions that
are only used for error recovery (eg plpgsql exceptions). Also, arrange
to release a subtransaction's XID lock as soon as the subtransaction
exits, in both the commit and abort cases. This avoids holding many
unique locks after a long series of subtransactions. The price is some
additional overhead in XactLockTableWait, but that seems acceptable.
Finally, restructure the state machine in xact.c to have a more orthogonal
set of states for subtransactions.
Bruce Momjian [Tue, 14 Sep 2004 14:34:45 +0000 (14:34 +0000)]
Mark as done:
< * Point-in-time data recovery using backup and write-ahead log,
< * Create native Win32 port, http://momjian.postgresql.org/main/writings/pgsql/project/win32.html
> * -Point-in-time data recovery using backup and write-ahead log
> * -Create native Win32 port 470c470
< o Fix PL/pgSQL RENAME to work on variables other than OLD/NEW
> o Fix PL/pgSQL RENAME to work on variables other than OLD/NEW
Tom Lane [Mon, 13 Sep 2004 20:10:13 +0000 (20:10 +0000)]
Redesign query-snapshot timing so that volatile functions in READ COMMITTED
mode see a fresh snapshot for each command in the function, rather than
using the latest interactive command's snapshot. Also, suppress fresh
snapshots as well as CommandCounterIncrement inside STABLE and IMMUTABLE
functions, instead using the snapshot taken for the most closely nested
regular query. (This behavior is only sane for read-only functions, so
the patch also enforces that such functions contain only SELECT commands.)
As per my proposal of 6-Sep-2004; I note that I floated essentially the
same proposal on 19-Jun-2002, but that discussion tailed off without any
action. Since 8.0 seems like the right place to be taking possibly
nontrivial backwards compatibility hits, let's get it done now.
Tom Lane [Sun, 12 Sep 2004 18:30:50 +0000 (18:30 +0000)]
When LockAcquire fails at the stage of creating a proclock object, be
sure to clean up the already-created lock object, if it has no other
references. Avoids possibly-permanent leak of shared memory.
Tom Lane [Sat, 11 Sep 2004 18:28:34 +0000 (18:28 +0000)]
Renumber SnapshotNow and the other special snapshot codes so that
((Snapshot) NULL) can no longer be confused with a valid snapshot,
as per my recent suggestion. Define a macro InvalidSnapshot for 0.
Use InvalidSnapshot instead of SnapshotAny as the do-nothing special
case for heap_update and heap_delete crosschecks; this seems a little
cleaner even though the behavior is really the same.
Tom Lane [Sat, 11 Sep 2004 15:56:46 +0000 (15:56 +0000)]
Ensure that pg_largeobject references opened by lo_import() or lo_export()
will be cleaned up at end of transaction, even when there is no other LO
operation in the transaction. Per bug report from Daniel Schuchardt.
Tom Lane [Fri, 10 Sep 2004 20:05:18 +0000 (20:05 +0000)]
Fix some problems with restoring databases owned by non-superusers,
as per bug #1249; and remove the last vestiges of using \connect to
change authorization.
Tom Lane [Fri, 10 Sep 2004 18:40:09 +0000 (18:40 +0000)]
Fire non-deferred AFTER triggers immediately upon query completion,
rather than when returning to the idle loop. This makes no particular
difference for interactively-issued queries, but it makes a big difference
for queries issued within functions: trigger execution now occurs before
the calling function is allowed to proceed. This responds to numerous
complaints about nonintuitive behavior of foreign key checking, such as
http://archives.postgresql.org/pgsql-bugs/2004-09/msg00020.php, and
appears to be required by the SQL99 spec.
Also take the opportunity to simplify the data structures used for the
pending-trigger list, rename them for more clarity, and squeeze out a
bit of space.
Neil Conway [Fri, 10 Sep 2004 04:31:06 +0000 (04:31 +0000)]
Apply patch from Steven Singer for contrib/dbmirror. Changes:
-It fixes up some bugs with handling setval calls
-Adds upgrade instructions from prior versions
-Improved the sample config file
-Fixed some things in the clean_pending script
Neil Conway [Fri, 10 Sep 2004 04:10:53 +0000 (04:10 +0000)]
psql consistency fixes from Greg Sabino Mullane: have \df show schema and
name first, make sure \di+ shows description last, and make \dl SQL look
a little more standard.
Tom Lane [Wed, 8 Sep 2004 23:47:58 +0000 (23:47 +0000)]
Minor efficiency improvements in keeping track of trigger deferred
status. In particular, I see no reason for deferredTriggerCheckState
to make an explicit entry to note that a particular trigger has its
default state --- that just clutters a list that should normally be
empty or very short. I have plans to revise this module much more
heavily, but this is a simple separable improvement.
Tom Lane [Mon, 6 Sep 2004 23:33:48 +0000 (23:33 +0000)]
Fix a number of places where brittle data structures or overly strong
Asserts would lead to a server core dump if an error occurred while
trying to abort a failed subtransaction (thereby leading to re-execution
of whatever parts of AbortSubTransaction had already run). This of course
does not prevent such an error from creating an infinite loop, but at
least we don't make the situation worse. Responds to an open item on
the subtransactions to-do list.
Tom Lane [Mon, 6 Sep 2004 17:56:33 +0000 (17:56 +0000)]
Fix incorrect ordering of smgr cleanup relative to buffer pin cleanup
during transaction abort. Add a regression test case to catch related
mistakes in future. Alvaro Herrera and Tom Lane.
Tom Lane [Sun, 5 Sep 2004 03:42:13 +0000 (03:42 +0000)]
On further consideration, there's another problem here: the existing
elog() emulation code always calls errstart with ERROR error level.
This means that a recursive error call triggered by elog would do
MemoryContextReset(ErrorContext), whether or not this was actually
appropriate. I'm surprised we haven't seen this in the field...
Tom Lane [Sun, 5 Sep 2004 02:01:41 +0000 (02:01 +0000)]
Tweak elog.c's logic for promoting errors into more severe errors.
Messages of less than ERROR severity should never be promoted (this
fixes Gaetano Mendola's problem with a COMMERROR becoming a PANIC,
and is obvious in hindsight anyway). Do all promotion in errstart
not errfinish, to ensure that output decisions are made correctly;
the former coding could suppress logging of promoted errors, which
doesn't seem like a good idea. Eliminate some redundant code too.
Tom Lane [Thu, 2 Sep 2004 23:06:43 +0000 (23:06 +0000)]
Fix shared library linking operations to work properly on all (or at
least more) combinations of HP-UX hardware, compiler, and linker.
Shinji Teragaito and Tom Lane.
Bruce Momjian [Thu, 2 Sep 2004 01:03:59 +0000 (01:03 +0000)]
This patch attempts to fix the issue with localized timezones on
Windows.
Recap: When running on a localized windows version, the timezone name
returned is also localized, and therefor does not match our lookup
table.
Solution: The registry contains both the name of the timezone in english
and the localized name. The patch adds code to scan the registry for the
localized name and gets the english name from that, and then rescans the
table.
I have tested this on a Swedish WinXP, and it works without problems.
The registry layout is the same in Win2k, but I haven't specifically
tested it. It's also the same on different languages but again only
Swedish is tested.
Bruce Momjian [Thu, 2 Sep 2004 00:55:22 +0000 (00:55 +0000)]
The current implementation of dbsize doesn't handle tables in
tablespaces correctly, and is quite restricted on objects covered (only
tables and databases, but not tablespaces and indexes).
The attached patch contributes:
- database_size(name)
- relation_size(text)
These are the well-known functions, tablespace-aware.
- pg_tablespace_size(oid)
- pg_database_size(oid)
- pg_relation_size(oid)
Tablespace-aware implementations, used by the upper functions.
pg_relation_size will report sizes of indexes as well.
- pg_size_pretty(bigint)
Formatting of sizes, to display '146MB' instead of '152885668'
Tom Lane [Wed, 1 Sep 2004 17:25:40 +0000 (17:25 +0000)]
Whack Wisconsin benchmark around until it actually works again.
It's still useless because it tests a standalone backend, but at least
the bit rot is repaired.