Neil Conway [Mon, 17 Jul 2006 00:21:23 +0000 (00:21 +0000)]
Improve psql's \df slash command to include the argument names and modes
(OUT or INOUT) of the function. Patch from David Fetter, editorialization
by Neil Conway.
Neil Conway [Sun, 16 Jul 2006 23:59:58 +0000 (23:59 +0000)]
Minor documentation tweak: in the tables of functions and operators,
don't include a space between the function name and the parenthesis
that begins its parameter list, for consistency.
Tom Lane [Sun, 16 Jul 2006 20:17:04 +0000 (20:17 +0000)]
In a Windows backend, don't build src/port/pgsleep.c's version of
pg_usleep at all. Instead call the replacement function in
port/win32/signal.c by that name. Avoids tricky macro-redefinition
logic and suppresses a compiler warning; furthermore it ensures that
no one can accidentally use the non-signal-aware version of pg_usleep
in a Windows backend.
Tom Lane [Sun, 16 Jul 2006 18:17:14 +0000 (18:17 +0000)]
Ensure that we retry rather than erroring out when send() or recv() return
EINTR; the stats code was failing to do this and so were a couple of places
in the postmaster. The stats code assumed that recv() could not return EINTR
if a preceding select() showed the socket to be read-ready, but this is
demonstrably false with our Windows implementation of recv(), and it may
not be the case on all Unix variants either. I think this explains the
intermittent stats regression test failures we've been seeing, as well
as reports of stats collector instability under high load on Windows.
Tom Lane [Sun, 16 Jul 2006 01:35:28 +0000 (01:35 +0000)]
Fix lack of repeat-inclusion guard in win32 substitute sys/socket.h.
I think this explains the 'implicit declaration of function gai_strerror'
warnings visible in the current buildfarm report from snake: if
sys/socket.h is included again after getaddrinfo.h, the file would
merrily undefine the gai_strerror macro.
Tom Lane [Sun, 16 Jul 2006 00:54:22 +0000 (00:54 +0000)]
Fix getDatumCopy(): don't use store_att_byval to copy into a Datum
variable (this accounts for regression failures on PPC64, and in fact
won't work on any big-endian machine). Get rid of hardwired knowledge
about datum size rules; make it look just like datumCopy().
Tom Lane [Sat, 15 Jul 2006 15:47:17 +0000 (15:47 +0000)]
Put back some more not-so-unused-as-all-that #includes. This un-breaks
the EXEC_BACKEND code on my machines, so hopefully it will fix the
Windows buildfarm members.
Tom Lane [Sat, 15 Jul 2006 03:33:14 +0000 (03:33 +0000)]
Fix some makefiles that fail to yield good results from 'make -qp'.
This doesn't really matter for ordinary building of Postgres, but it's
useful for automated checks, such as my just-committed pgcheckdefines.
Tom Lane [Sat, 15 Jul 2006 03:27:42 +0000 (03:27 +0000)]
Create a tool to catch #include omissions that might not result in any
compiler warning, specifically #ifdef or #if defined tests on symbols
that are defined in a file not included. The results are a bit noisy
and require care to interpret, but it's a lot better than no tool at all.
Tom Lane [Fri, 14 Jul 2006 19:05:52 +0000 (19:05 +0000)]
Fix misguided removal of access/tuptoaster.h inclusion, per Kris Jurka.
I'm going to insist on reversion of this entire patch unless pgrminclude
is upgraded to a less broken state, but in the meantime let's get contrib
passing regression again.
Tom Lane [Fri, 14 Jul 2006 05:28:29 +0000 (05:28 +0000)]
Fix a passel of recently-committed violations of the rule 'thou shalt
have no other gods before c.h'. Also remove some demonstrably redundant
#include lines, mostly of <errno.h> which was added to c.h years ago.
Neil Conway [Thu, 13 Jul 2006 23:59:47 +0000 (23:59 +0000)]
Reorder the entries in the function section of the manual, to ensure they
are alphabetically ordered. I believe the tables were correctly ordered in
the past, but some of them had subsequently regressed.
Joe Conway [Wed, 12 Jul 2006 02:31:56 +0000 (02:31 +0000)]
Clean up for warning:
fe-auth.c:573: warning: passing argument 1 of 'free' discards qualifiers
from pointer target type
pg_krb5_authname used to return a (const char *) to memory allocated by
krb. Somewhere along the lines this was changed so that a copy was
made, returned, and freed instead. However the const modifier was never
removed.
Apply entab fix from Marko Kreen for these problems:
- halt.c did not include stdlib.h, thus missed exit() prototype
- Makefile ignores BINDIR for install.
- Makefile calls install with user/group args, thus failing for regular user.
While trying it I noticed that the Makefile does not support VPATH builds ...
Tom Lane [Tue, 11 Jul 2006 21:05:57 +0000 (21:05 +0000)]
Tweak fillfactor code as per my recent proposal. Fix nbtsort.c so that
it can handle small fillfactors for ordinary-sized index entries without
failing on large ones; fix nbtinsert.c to distinguish leaf and nonleaf
pages; change the minimum fillfactor to 10% for all index types.
GIN improvements
- Replace sorted array of entries in maintenance_work_mem to binary tree,
this should improve create performance.
- More precisely calculate allocated memory, eliminate leaks
with user-defined extractValue()
- Improve wordings in tsearch2
Tom Lane [Mon, 10 Jul 2006 22:10:39 +0000 (22:10 +0000)]
Fix ALTER TABLE to check pre-existing NOT NULL constraints when rewriting
a table. Otherwise a USING clause that yields NULL can leave the table
violating its constraint (possibly there are other cases too). Per report
from Alexander Pravking.
Improve vacuum code to track minimum Xids per table instead of per database.
To this end, add a couple of columns to pg_class, relminxid and relvacuumxid,
based on which we calculate the pg_database columns after each vacuum.
We now force all databases to be vacuumed, even template ones. A backend
noticing too old a database (meaning pg_database.datminxid is in danger of
falling behind Xid wraparound) will signal the postmaster, which in turn will
start an autovacuum iteration to process the offending database. In principle
this is only there to cope with frozen (non-connectable) databases without
forcing users to set them to connectable, but it could force regular user
database to go through a database-wide vacuum at any time. Maybe we should
warn users about this somehow. Of course the real solution will be to use
autovacuum all the time ;-)
There are some additional improvements we could have in this area: for example
the vacuum code could be smarter about not updating pg_database for each table
when called by autovacuum, and do it only once the whole autovacuum iteration
is done.
I updated the system catalogs documentation, but I didn't modify the
maintenance section. Also having some regression tests for this would be nice
but it's not really a very straightforward thing to do.
Catalog version bumped due to system catalog changes.
Bruce Momjian [Thu, 6 Jul 2006 02:18:07 +0000 (02:18 +0000)]
Add index information to /contrib/pgstattuple:
This is an extension of pgstattuple to query information from indexes.
It supports btree, hash and gist. Gin is not supported. It scans only
index pages and does not read corresponding heap tuples. Therefore,
'dead_tuple' means the number of tuples with LP_DELETE flag.
Also, I added an experimental feature for btree indexes. It checks
fragmentation factor of indexes. If an leaf has the right link on the
next adjacent page in the file, it is assumed to be continuous (not
fragmented). It will help us to decide when to REINDEX.
Bruce Momjian [Thu, 6 Jul 2006 01:57:25 +0000 (01:57 +0000)]
Backpatch dbmirror fix for escape handling.
> Upstream confirmed my reply in the last mail in [1]: the complete
> escaping logic in DBMirror.pl is seriously screwew.
>
> [1] http://archives.postgresql.org/pgsql-bugs/2006-06/msg00065.php
I finally found some time to debug this, and I think I found a better
patch than the one you proposed. Mine is still hackish and is still a
workaround around a proper quoting solution, but at least it repairs
the parsing without introducing the \' quoting again.
I consider this a band-aid patch to fix the recent security update.
PostgreSQL gurus, would you consider applying this until a better
solution is found for DBMirror.pl?
Olivier, can you please confirm that the patch works for you, too?
Bruce Momjian [Thu, 6 Jul 2006 01:55:51 +0000 (01:55 +0000)]
Attached patch is required ot build with the CRT that comes with Visual
Studio 2005. Basically MS defined errcode in the headers with a typedef,
so we have to #define it out of the way.
While at it, fix a function declaration in plpython that didn't match
the implementation (volatile missing).
Tom Lane [Mon, 3 Jul 2006 22:45:41 +0000 (22:45 +0000)]
Code review for FILLFACTOR patch. Change WITH grammar as per earlier
discussion (including making def_arg allow reserved words), add missed
opt_definition for UNIQUE case. Put the reloptions support code in a less
random place (I chose to make a new file access/common/reloptions.c).
Eliminate header inclusion creep. Make the index options functions safely
user-callable (seems like client apps might like to be able to test validity
of options before trying to make an index). Reduce overhead for normal case
with no options by allowing rd_options to be NULL. Fix some unmaintainably
klugy code, including getting rid of Natts_pg_class_fixed at long last.
Some stylistic cleanup too, and pay attention to keeping comments in sync
with code.
Documentation still needs work, though I did fix the omissions in
catalogs.sgml and indexam.sgml.
Neil Conway [Sun, 2 Jul 2006 05:17:26 +0000 (05:17 +0000)]
Do a pass of code review for the ALTER TABLE ADD INHERITS patch. Keep
the read lock we hold on the table's parent relation until commit.
Update equalfuncs.c for the new field in AlterTableCmd. Various
improvements to comments, variable names, and error reporting.
There is room for further improvement here, but this is at least
a step in the right direction.
Bruce Momjian [Sun, 2 Jul 2006 01:59:46 +0000 (01:59 +0000)]
Done:
< o Add ALTER TABLE tab ADD/DROP INHERITS parent
<
< This allows tables to be added/removed from an inheritance
< hierarchy. This is particularly useful for table partitioning.
< http://archives.postgresql.org/pgsql-hackers/2006-05/msg00988.php
<
> o -Add ALTER TABLE tab INHERIT / NO INHERIT parent
Bruce Momjian [Sun, 2 Jul 2006 01:58:36 +0000 (01:58 +0000)]
ALTER TABLE ... ADD/DROPS INHERIT (actually INHERIT / NO INHERIT)
Open items:
There were a few tangentially related issues that have come up that I think
are TODOs. I'm likely to tackle one or two of these next so I'm interested in
hearing feedback on them as well.
. Constraints currently do not know anything about inheritance. Tom suggested
adding a coninhcount and conislocal like attributes have to track their
inheritance status.
. Foreign key constraints currently do not get copied to new children (and
therefore my code doesn't verify them). I don't think it would be hard to
add them and treat them like CHECK constraints.
. No constraints at all are copied to tables defined with LIKE. That makes it
hard to use LIKE to define new partitions. The standard defines LIKE and
specifically says it does not copy constraints. But the standard already has
an option called INCLUDING DEFAULTS; we could always define a non-standard
extension LIKE table INCLUDING CONSTRAINTS that gives the user the option to
request a copy including constraints.
. Personally, I think the whole attislocal thing is bunk. The decision about
whether to drop a column from children tables or not is something that
should be up to the user and trying to DWIM based on whether there was ever
a local definition or the column was acquired purely through inheritance is
hardly ever going to match up with user expectations.
. And of course there's the whole unique and primary key constraint issue. I
think to get any traction at all on this you have a prerequisite of a real
partitioned table implementation where the system knows what the partition
key is so it can recognize when it's a leading part of an index key.
Tom Lane [Sat, 1 Jul 2006 22:07:23 +0000 (22:07 +0000)]
Fix oversight in planning for multiple indexscans driven by
ScalarArrayOpExpr index quals: we were estimating the right total
number of rows returned, but treating the index-access part of the
cost as if a single scan were fetching that many consecutive index
tuples. Actually we should treat it as a multiple indexscan, and
if there are enough of 'em the Mackert-Lohman discount should kick in.
Tom Lane [Sat, 1 Jul 2006 18:38:33 +0000 (18:38 +0000)]
Revise the planner's handling of "pseudoconstant" WHERE clauses, that is
clauses containing no variables and no volatile functions. Such a clause
can be used as a one-time qual in a gating Result plan node, to suppress
plan execution entirely when it is false. Even when the clause is true,
putting it in a gating node wins by avoiding repeated evaluation of the
clause. In previous PG releases, query_planner() would do this for
pseudoconstant clauses appearing at the top level of the jointree, but
there was no ability to generate a gating Result deeper in the plan tree.
To fix it, get rid of the special case in query_planner(), and instead
process pseudoconstant clauses through the normal RestrictInfo qual
distribution mechanism. When a pseudoconstant clause is found attached to
a path node in create_plan(), pull it out and generate a gating Result at
that point. This requires special-casing pseudoconstants in selectivity
estimation and cost_qual_eval, but on the whole it's pretty clean.
It probably even makes the planner a bit faster than before for the normal
case of no pseudoconstants, since removing pull_constant_clauses saves one
useless traversal of the qual tree. Per gripe from Phil Frost.