Neil Conway [Sun, 14 Dec 2003 00:34:47 +0000 (00:34 +0000)]
I posted some bufmgr cleanup a few weeks ago, but it conflicted with
some concurrent changes Jan was making to the bufmgr. Here's an
updated version of the patch -- it should apply cleanly to CVS
HEAD and passes the regression tests.
This patch makes the following changes:
- remove the UnlockAndReleaseBuffer() and UnlockAndWriteBuffer()
macros, and replace uses of them with calls to the appropriate
functions.
- remove a bunch of #ifdef BMTRACE code: it is ugly & broken
(i.e. it doesn't compile)
- make BufferReplace() return a bool, not an int
- cleanup some logic in bufmgr.c; should be functionality
equivalent to the previous code, just cleaner now
Neil Conway [Sun, 14 Dec 2003 00:10:32 +0000 (00:10 +0000)]
This patch makes some improvements and adds some additional detail
to the documentation on routine database maintainence activities.
I also corrected a bunch of SGML markup.
Peter Eisentraut [Fri, 12 Dec 2003 18:45:10 +0000 (18:45 +0000)]
This patch properly sets the prototype for the on_shmem_exit and
on_proc_exit functions, and adjust all other related code to use
the proper types too.
Tom Lane [Tue, 9 Dec 2003 01:56:20 +0000 (01:56 +0000)]
query_tree_mutator should copy RangeTblEntry nodes even when it's not
planning to modify them itself. Otherwise we end up with shared RTE
substructure, which breaks inheritance_planner because the rte->inh
flag needs to be independent in each copied subquery. Per bug report
from Chris Piker.
Tom Lane [Mon, 8 Dec 2003 18:19:58 +0000 (18:19 +0000)]
Whole-row references were broken for subqueries and functions, because
attr_needed/attr_widths optimization failed to allow for Vars with attno
zero in this case. Per report from Tatsuo Ishii.
Tom Lane [Sun, 7 Dec 2003 19:43:02 +0000 (19:43 +0000)]
Remove test on c.relkind from check_constraints view; unnecessary and
prevents view from showing constraints on domains. This addresses the
other half of Claus Colloseus' bug report.
Tom Lane [Sun, 7 Dec 2003 05:44:50 +0000 (05:44 +0000)]
One more pass at reducing the cost of pg_dump's new implementation:
reduce the number of times TopoSort() has to be executed by trying to
extract multiple dependency loops from each pass, instead of only one.
This saves about another factor of ten on the regression database.
This could be considered as another exercise in grokking Fred Brooks'
maxim: Representation *is* the essence of programming.
Joe Conway [Sun, 7 Dec 2003 04:14:10 +0000 (04:14 +0000)]
Repair indexed bytea like operations, and related selectivity
functionality. Per bug report by Alvar Freude:
http://archives.postgresql.org/pgsql-bugs/2003-12/msg00022.php
Tom Lane [Sat, 6 Dec 2003 22:55:11 +0000 (22:55 +0000)]
Replace not-very-bright implementation of topological sort with a better
one (use a priority heap to keep track of items ready to output, instead
of searching the input array each time). This brings the runtime of
pg_dump back to about what it was in 7.4.
Tom Lane [Sat, 6 Dec 2003 03:00:16 +0000 (03:00 +0000)]
Massive overhaul of pg_dump: make use of dependency information from
pg_depend to determine a safe dump order. Defaults and check constraints
can be emitted either as part of a table or domain definition, or
separately if that's needed to break a dependency loop. Lots of old
half-baked code for controlling dump order removed.
Joe Conway [Wed, 3 Dec 2003 18:52:00 +0000 (18:52 +0000)]
Added new group of read-only GUC variables to allow simple access
to certain compile-time options (FUNC_MAX_ARGS, INDEX_MAX_KEYS,
NAMEDATALEN, BLCKSZ, HAVE_INT64_TIMESTAMP). Also added "category",
"short_desc", and "extra_desc" to the pg_settings view. Per recent
discussion here:
http://archives.postgresql.org/pgsql-patches/2003-11/msg00363.php
Tom Lane [Wed, 3 Dec 2003 17:45:10 +0000 (17:45 +0000)]
Planner failed to be smart about binary-compatible expressions in pathkeys
and hash bucket-size estimation. Issue has been there awhile but is more
critical in 7.4 because it affects varchar columns. Per report from
Greg Stark.
Joe Conway [Tue, 2 Dec 2003 19:26:47 +0000 (19:26 +0000)]
Add a warning to AtEOXact_SPI() to catch cases where the current
transaction has been committed without SPI_finish() being called
first. Per recent discussion here:
http://archives.postgresql.org/pgsql-patches/2003-11/msg00286.php
Bruce Momjian [Mon, 1 Dec 2003 23:19:33 +0000 (23:19 +0000)]
I've run across a pretty serious problem with pg_autovacuum.
pg_autovacuum looses track of any table that's ever been truncated
(possibly other situations too). When i truncate a table it gets a
new relfilenode in pg_class. This is a problem because pg_autovacuum
assumes pg_class.relfilenode will join to pg_stats_all_tables.relid.
pg_stats_all_tables.relid is actallly the oid from pg_class, not the
relfilenode. These two values start out equal so pg_autovacuum works
initially, but it fails later on because of this incorrect assumption.
This patch fixes that problem. Applied to HEAD and 7.4.X.
Bruce Momjian [Mon, 1 Dec 2003 23:13:07 +0000 (23:13 +0000)]
I noticed in the 7.4 release that in contrib/pg_autovacuum, args->logfile is
not initialized if a log file is not specified on the command line. This
causes an immediate segfault on systems that fill allocated memory with some
value other than zero (my FreeBSD machine uses 0xD0).
Several crashes later I discovered that args->user, password, host, and port
are also used without being initialized.
This doesn't appear to be fixed in CVS and I came up empty on a mailing list
search -- hope it hasn't been reported already.
Bruce Momjian [Mon, 1 Dec 2003 23:12:16 +0000 (23:12 +0000)]
The attached patch enables contrib/cube to build cleanly under Cygwin
(again). Please consider this patch for the 7.4.1 branch (if there will
be one) too.
Bruce Momjian [Mon, 1 Dec 2003 22:22:44 +0000 (22:22 +0000)]
Update for patches applied:
< * Change factorial to return a numeric
> * -Change factorial to return a numeric (Gavin) 258c258
< * Allow psql \du to show groups, and add \dg for groups
> * -Allow psql \du to show groups, and add \dg for groups
Tom Lane [Mon, 1 Dec 2003 22:15:38 +0000 (22:15 +0000)]
Avoid assuming that type key_t is 32 bits, since it reportedly isn't
on 64-bit Solaris. Use a non-system-dependent datatype for UsedShmemSegID,
namely unsigned long (which we were already assuming could hold a shmem
key anyway, cf RecordSharedMemoryInLockFile).
Bruce Momjian [Mon, 1 Dec 2003 22:14:40 +0000 (22:14 +0000)]
This patch reduces some unsightly #ifdefs, and fixes two typos in
comments in the psql code. This doesn't make any functional change, so
feel free to save it for 7.5
Bruce Momjian [Mon, 1 Dec 2003 22:11:06 +0000 (22:11 +0000)]
This patch finishes off the work that I did with making view
definitions use pretty printing.
It does:
* Pretty index predicates
* Pretty rule definitions
* Uppercases PRIMARY KEY and UNIQUE to be consistent with CHECK and
FOREIGN KEY
* View rules are improved to match table rules:
Bruce Momjian [Mon, 1 Dec 2003 22:08:02 +0000 (22:08 +0000)]
This patch adds a new GUC var, "default_with_oids", which follows the
proposal for eventually deprecating OIDs on user tables that I posted
earlier to pgsql-hackers. pg_dump now always specifies WITH OIDS or
WITHOUT OIDS when dumping a table. The documentation has been updated.
Bruce Momjian [Mon, 1 Dec 2003 21:59:25 +0000 (21:59 +0000)]
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
Bruce Momjian [Mon, 1 Dec 2003 21:52:38 +0000 (21:52 +0000)]
Attached is a patch implementing factorial(), returning numeric. Points
to note:
1) arttype is numeric. I thought this was the best way of allowing
arbitarily large factorials, even though factorial(2^63) is a large
number. Happy to change to integers if this is overkill.
2) since we're accepting numeric arguments, the patch tests for floats.
If a numeric is passed with non-zero decimal portion, an error is raised
since (from memory) they are undefined.
Tom Lane [Mon, 1 Dec 2003 16:53:19 +0000 (16:53 +0000)]
Force zero_damaged_pages to be effectively ON during recovery from WAL,
since there is no need to worry about damaged pages when we are going to
overwrite them anyway from the WAL. Per recent discussion.
Joe Conway [Sun, 30 Nov 2003 20:55:09 +0000 (20:55 +0000)]
Make PQescapeBytea and byteaout consistent with each other, and
octal escape all octets outside the range 0x20 to 0x7e. This fixes
the problem pointed out by Sergey Yatskevich here:
http://archives.postgresql.org/pgsql-bugs/2003-11/msg00140.php