Tom Lane [Sat, 2 Sep 2006 17:06:52 +0000 (17:06 +0000)]
Apply a simple solution to the problem of making INSERT/UPDATE/DELETE
RETURNING play nice with views/rules. To wit, have the rule rewriter
rewrite any RETURNING clause found in a rule to produce what the rule's
triggering query asked for in its RETURNING clause, in particular drop
the RETURNING clause if no RETURNING in the triggering query. This
leaves the responsibility for knowing how to produce the view's output
columns on the rule author, without requiring any fundamental changes
in rule semantics such as adding new rule event types would do. The
initial implementation constrains things to ensure that there is
exactly one, unconditionally invoked RETURNING clause among the rules
for an event --- later we might be able to relax that, but for a post
feature freeze fix it seems better to minimize how much invention we do.
Per gripe from Jaime Casanova.
Bruce Momjian [Sat, 2 Sep 2006 13:12:50 +0000 (13:12 +0000)]
Add new variable "server_version_num", which is almost the same as
"server_version" but uses the handy PG_VERSION_NUM which allows apps to
do things like if ($version >= 80200) without having to parse apart the
value of server_version themselves.
Tom Lane [Thu, 31 Aug 2006 17:31:33 +0000 (17:31 +0000)]
Clean up rather sloppy fix in HEAD for the ancient bug that CREATE CONVERSION
didn't create a dependency from the new conversion to its schema. Back-patch
to all supported releases.
Bruce Momjian [Thu, 31 Aug 2006 00:34:34 +0000 (00:34 +0000)]
Done:
< Last updated: Tue Aug 29 12:21:52 EDT 2006
> Last updated: Wed Aug 30 20:34:28 EDT 2006
< o Allow COPY (SELECT ...) TO 'filename'
<
< COPY should also be able to output views using COPY (SELECT
< * FROM view) TO 'filename' internally.
< http://archives.postgresql.org/pgsql-patches/2005-09/msg00148.php
> o -Allow COPY (SELECT ...) TO 'filename'
Tom Lane [Wed, 30 Aug 2006 18:06:27 +0000 (18:06 +0000)]
Fix things so that fopen's, not only open's, pass FILE_SHARE_DELETE
and other special flags on Windows. May fix intermittent 'Permission
denied' errors. Magnus Hagander
Tom Lane [Tue, 29 Aug 2006 22:25:08 +0000 (22:25 +0000)]
Create a FETCH_COUNT parameter that causes psql to execute SELECT-like
queries via a cursor, fetching a limited number of rows at a time and
therefore not risking exhausting memory. A disadvantage of the scheme
is that 'aligned' output mode will align each group of rows independently
leading to odd-looking output, but all the other output formats work
reasonably well. Chris Mair, with some additional hacking by moi.
Tom Lane [Tue, 29 Aug 2006 15:19:51 +0000 (15:19 +0000)]
Invent an assign-hook mechanism for psql variables similar to the one
existing for backend GUC variables, and use this to eliminate repeated
fetching/parsing of psql variables in psql's inner loops. In a trivial
test with lots of 'select 1;' commands, psql's CPU time went down almost
10%, although of course the effect on total elapsed time was much less.
Per discussion about how to ensure the upcoming FETCH_COUNT patch doesn't
cost any performance when not being used.
Bruce Momjian [Tue, 29 Aug 2006 02:11:30 +0000 (02:11 +0000)]
Now bind displays prepare as detail, and execute displays prepare and
optionally bind. I re-added the "statement:" label so people will
understand why the line is being printed (it is log_*statement
behavior).
Use single quotes for bind values, instead of double quotes, and double
literal single quotes in bind values (and document that). I also made
use of the DETAIL line to have much cleaner output.
Bruce Momjian [Mon, 28 Aug 2006 23:21:46 +0000 (23:21 +0000)]
Move to referential integrity section:
> o Allow DEFERRABLE and end-of-statement UNIQUE constraints?
>
> This would allow UPDATE tab SET col = col + 1 to work if col has
> a unique index. Currently, uniqueness checks are done while the
> command is being executed, rather than at the end of the statement
> or transaction.
>
<
< * Allow DEFERRABLE and end-of-statement UNIQUE constraints?
<
< This would allow UPDATE tab SET col = col + 1 to work if col has
< a unique index. Currently, uniqueness checks are done while the
< command is being executed, rather than at the end of the statement
< or transaction.
Bruce Momjian [Mon, 28 Aug 2006 23:20:35 +0000 (23:20 +0000)]
Update:
< * Allow DEFERRABLE UNIQUE constraints?
> * Allow DEFERRABLE and end-of-statement UNIQUE constraints?
>
> This would allow UPDATE tab SET col = col + 1 to work if col has
> a unique index. Currently, uniqueness checks are done while the
> command is being executed, rather than at the end of the statement
> or transaction.
>
Tom Lane [Mon, 28 Aug 2006 19:38:09 +0000 (19:38 +0000)]
Fix pgstat_report_waiting() to not dump core if called before
pgstat_bestart() has been called; else any lock-block occurring
during InitPostgres() is disastrous. I believe this explains
recent wasp regression failure; at least it explains the crash I
got while trying to duplicate the problem. I also made
pgstat_report_activity() safe against the same scenario, just
in case. The report_waiting hazard was created by my patch of
19-Aug to include waiting status in pg_stat_activity.
Tom Lane [Mon, 28 Aug 2006 16:13:11 +0000 (16:13 +0000)]
Partial fix for ecpg's VPATH problems. It compiles and successfully
builds all the files needed for its regression tests, but the tests
themselves fail because of diffs in the #line directives output by
ecpg itself. Not sure what to do about that.
Tom Lane [Mon, 28 Aug 2006 14:32:41 +0000 (14:32 +0000)]
Tweak trivial_subqueryscan() to consider a SubqueryScan's targetlist
trivial if it contains either Vars referencing the corresponding subplan
columns, or Consts equaling the corresponding subplan columns. This
lets the planner eliminate the SubqueryScan in some cases generated by
generate_setop_tlist().
Tom Lane [Sun, 27 Aug 2006 23:47:58 +0000 (23:47 +0000)]
Add new return codes SPI_OK_INSERT_RETURNING etc to the SPI API.
Fix all the standard PLs to be able to return tuples from FOO_RETURNING
statements as well as utility statements that return tuples. Also,
fix oversight that SPI_processed wasn't set for a utility statement
returning tuples. Per recent discussion.
Tom Lane [Sun, 27 Aug 2006 21:41:21 +0000 (21:41 +0000)]
Add some notes about why it's not a bug that RI_FKey_check calls
HeapTupleSatisfiesItself without doing LockBuffer first. This code
is a bit fragile, but AFAICS it's not actually broken.
Tom Lane [Sun, 27 Aug 2006 19:14:34 +0000 (19:14 +0000)]
Add a function GetLockConflicts() to lock.c to report xacts holding
locks that would conflict with a specified lock request, without
actually trying to get that lock. Use this instead of the former ad hoc
method of doing the first wait step in CREATE INDEX CONCURRENTLY.
Fixes problem with undetected deadlock and in many cases will allow the
index creation to proceed sooner than it otherwise could've. Per
discussion with Greg Stark.
Tom Lane [Fri, 25 Aug 2006 04:06:58 +0000 (04:06 +0000)]
Add the ability to create indexes 'concurrently', that is, without
blocking concurrent writes to the table. Greg Stark, with a little help
from Tom Lane.
Tom Lane [Thu, 24 Aug 2006 03:15:43 +0000 (03:15 +0000)]
Add some debug logging code to AllocateFile's failure path to log the
specific Windows error code (GetLastError). This is a hopefully temporary
hack to try to diagnose rare failures. Magnus Hagander
Tom Lane [Thu, 24 Aug 2006 01:18:34 +0000 (01:18 +0000)]
Optimize the case where a btree indexscan has current and mark positions
on the same index page; we can avoid data copying as well as buffer refcount
manipulations in this common case. Makes for a small but noticeable
improvement in mergejoin speed.
Bruce Momjian [Wed, 23 Aug 2006 18:32:02 +0000 (18:32 +0000)]
Add "AS" item:
< * All backends running as threads in a single process (not want)
> * All backends running as threads in a single process (not wanted)
< * Optimizer hints (not want)
> * Optimizer hints (not wanted)
>
> * Allow AS in "SELECT col AS label" to be optional (not wanted)
>
> Because we support postfix operators, it isn't possible to make AS
> optional and continue to use bison.
> http://archives.postgresql.org/pgsql-sql/2006-08/msg00164.php
Michael Meskes [Wed, 23 Aug 2006 12:01:53 +0000 (12:01 +0000)]
Replaced double-quote-fix with a hopefully better version.
Use initializer string length as size for character strings.
Added ecpg_config.h file that is created via configure.
Bruce Momjian [Wed, 23 Aug 2006 02:48:12 +0000 (02:48 +0000)]
Update COPY/VIEW item:
< o Allow COPY to output from SELECT
> o Allow COPY (SELECT ...) TO 'filename'
< COPY should also be able to output views.
> COPY should also be able to output views using COPY (SELECT
> * FROM view) TO 'filename' internally.
Tom Lane [Mon, 21 Aug 2006 19:21:38 +0000 (19:21 +0000)]
Fix encrypted-LDAP support so that it doesn't cause the server to fail
entirely on older Windows platforms without the needed library function.
Magnus Hagander
Tom Lane [Mon, 21 Aug 2006 19:15:29 +0000 (19:15 +0000)]
Minor code rearrangement to save a few cycles in RI_FKey_check when
the subject tuple is already deleted: we need not open the pk_rel
until after we check that.
Tom Lane [Mon, 21 Aug 2006 16:16:31 +0000 (16:16 +0000)]
Make the server track an 'XID epoch', that is, maintain higher-order bits
of the transaction ID counter. Nothing is done with the epoch except to
store it in checkpoint records, but this provides a foundation with which
add-on code can pretend that XIDs never wrap around. This is a severely
trimmed and rewritten version of the xxid patch submitted by Marko Kreen.
Per discussion, the epoch counter seems the only part of xxid that really
needs to be in the core server.
Bruce Momjian [Mon, 21 Aug 2006 12:20:26 +0000 (12:20 +0000)]
Remove items, not needed anymore:
< * %Disallow changing DEFAULT expression of a SERIAL column?
<
< This should be done only if the existing SERIAL problems cannot be
< fixed.
<
< * %Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
< does not dump the changes
Tom Lane [Mon, 21 Aug 2006 00:57:26 +0000 (00:57 +0000)]
Fix all known problems with pg_dump's handling of serial sequences
by abandoning the idea that it should say SERIAL in the dump. Instead,
dump serial sequences and column defaults just like regular ones.
Add a new backend command ALTER SEQUENCE OWNED BY to let pg_dump recreate
the sequence-to-column dependency that was formerly created "behind the
scenes" by SERIAL. This restores SERIAL to being truly "just a macro"
consisting of component operations that can be stated explicitly in SQL.
Furthermore, the new command allows sequence ownership to be reassigned,
so that old mistakes can be cleaned up.
Also, downgrade the OWNED-BY dependency from INTERNAL to AUTO, since there
is no longer any very compelling argument why the sequence couldn't be
dropped while keeping the column. (This forces initdb, to be sure the
right kinds of dependencies are in there.)
Along the way, add checks to prevent ALTER OWNER or SET SCHEMA on an
owned sequence; you can now only do this indirectly by changing the
owning table's owner or schema. This is an oversight in previous
releases, but probably not worth back-patching.
Alvaro Herrera [Sun, 20 Aug 2006 21:56:16 +0000 (21:56 +0000)]
Fix DROP OWNED BY to correctly consider the implicitly-deleted objects list for
each object to be deleted, instead of the previous hack that just skipped
INTERNAL dependencies, which didn't really work. Per report from Tom Lane.
To do this, introduce a new performMultipleDeletions entry point in
dependency.c to delete multiple objects at once. The dependency code then has
the responsability of tracking INTERNAL and AUTO dependencies as needed.
Along the way, change ObjectAddresses so that we can allocate an ObjectAddress
list from outside dependency.c and not have to export the internal
representation.
Tom Lane [Sat, 19 Aug 2006 02:48:53 +0000 (02:48 +0000)]
Suppress subquery pullup/pushdown when a subquery contains volatile
functions in its targetlist, to avoid introducing multiple evaluations
of volatile functions that textually appear only once. This is a
slightly tighter version of Jaime Casanova's recent patch.
Tom Lane [Sat, 19 Aug 2006 01:36:34 +0000 (01:36 +0000)]
Add a 'waiting' column to pg_stat_activity to carry the same information
that ps_status provides by appending 'waiting' to the PS display. This
completes the project of making it feasible to turn off process title
updates and instead rely on pg_stat_activity. Per my suggestion a few
weeks ago.
Tom Lane [Fri, 18 Aug 2006 19:52:39 +0000 (19:52 +0000)]
Add PQdescribePrepared, PQdescribePortal, and related functions to libpq
to allow obtaining information about previously prepared statements and
open cursors. Volkan Yazici
Tom Lane [Fri, 18 Aug 2006 16:09:13 +0000 (16:09 +0000)]
Now that we've rearranged relation open to get a lock before touching
the rel, it's easy to get rid of the narrow race-condition window that
used to exist in VACUUM and CLUSTER. Did some minor code-beautification
work in the same area, too.
Tom Lane [Thu, 17 Aug 2006 23:04:10 +0000 (23:04 +0000)]
Implement archive_timeout feature to force xlog file switches to occur no more
than N seconds apart. This allows a simple, if not very high performance,
means of guaranteeing that a PITR archive is no more than N seconds behind
real time. Also make pg_current_xlog_location return the WAL Write pointer,
add pg_current_xlog_insert_location to return the Insert pointer, and fix
pg_xlogfile_name_offset to return its results as a two-element record instead
of a smashed-together string, as per recent discussion.
Peter Eisentraut [Thu, 17 Aug 2006 17:25:43 +0000 (17:25 +0000)]
Produce a clean failure in configure when dtrace is selected but cannot be
found. Besides stopping those early who have no dtrace installed
whatsoever, this will also alert those who have dtrace in /usr/sbin, which
might not be in the path, which would produce confusing failures much later
in the build process.
Add documentation about pointing configure to find dtrace.