Commit Graph

33158 Commits

Author SHA1 Message Date
Robert Haas c5a03256c7 Adjust tuplesort.c based on the fact that we never use the OS's qsort().
Our own qsort_arg() implementation doesn't have the defect previously
observed to affect only QNX 4, so it seems sufficiently to assert that
it isn't broken rather than retesting.  Also, update a few comments to
clarify why it's valuable to retain a tie-break rule based on CTID
during index builds.

Peter Geoghegan, with slight tweaks by me.
2012-01-26 14:43:28 -05:00
Robert Haas 2d1371d3ee Be more clear when a new column name collides with a system column name.
We now use the same error message for ALTER TABLE .. ADD COLUMN or
ALTER TABLE .. RENAME COLUMN that we do for CREATE TABLE.  The old
message was accurate, but might be confusing to users not aware of our
system columns.

Vik Reykja, with some changes by me, and further proofreading by Tom Lane
2012-01-26 12:44:30 -05:00
Heikki Linnakangas d4bad4e1e1 Fix sentence in docs: checkpoints are not done by bgwriter anymore. 2012-01-26 19:08:20 +02:00
Heikki Linnakangas 6d90eaaa89 Make bgwriter sleep longer when it has no work to do, to save electricity.
To make it wake up promptly when activity starts again, backends nudge it
by setting a latch in MarkBufferDirty(). The latch is kept set while
bgwriter is active, so there is very little overhead from that when the
system is busy. It is only armed before going into longer sleep.

Peter Geoghegan, with some changes by me.
2012-01-26 18:39:13 +02:00
Robert Haas 467ff207f5 Add missing #include, to suppress compiler warning. 2012-01-26 10:16:26 -05:00
Magnus Hagander 7729e22d83 Fix a copy/pasted typo in several comments 2012-01-26 16:02:33 +01:00
Magnus Hagander 61cb8c5abb Add deadlock counter to pg_stat_database
Adds a counter that tracks number of deadlocks that occurred in
each database to pg_stat_database.

Magnus Hagander, reviewed by Jaime Casanova
2012-01-26 15:58:19 +01:00
Robert Haas 0e549697d1 Classify DROP operations by whether or not they are user-initiated.
This doesn't do anything useful just yet, but is intended as supporting
infrastructure for allowing sepgsql to sensibly check DROP permissions.

KaiGai Kohei and Robert Haas
2012-01-26 09:30:27 -05:00
Magnus Hagander bc3347484a Track temporary file count and size in pg_stat_database
Add counters for number and size of temporary files used
for spill-to-disk queries for each database to the
pg_stat_database view.

Tomas Vondra, review by Magnus Hagander
2012-01-26 14:41:19 +01:00
Robert Haas 9d35116611 Damage control for yesterday's CheckIndexCompatible changes.
Rip out a regression test that doesn't play well with settings put in
place by the build farm, and rewrite the code in CheckIndexCompatible
in a hopefully more transparent style.
2012-01-26 08:21:31 -05:00
Robert Haas 9f9135d129 Instrument index-only scans to count heap fetches performed.
Patch by me; review by Tom Lane, Jeff Davis, and Peter Geoghegan.
2012-01-25 20:41:52 -05:00
Alvaro Herrera 08146775ac Have \copy go through SendQuery
This enables a bunch of features, notably ON_ERROR_ROLLBACK.  It also
makes COPY failure (either in the server or psql) as a whole behave more
sanely in psql.

Additionally, having more commands in the same command line as COPY
works better (though since psql splits lines at semicolons, this doesn't
matter much unless you're using -c).

Also tighten a couple of switches on PQresultStatus() to add
PGRES_COPY_BOTH support and stop assuming that unknown statuses received
are errors; have those print diagnostics where warranted.

Author: Noah Misch
2012-01-25 18:22:00 -03:00
Robert Haas 6eb71ac552 Make CheckIndexCompatible simpler and more bullet-proof.
This gives up the "don't rewrite the index" behavior in a couple of
relatively unimportant cases, such as changing between an array type
and an unconstrained domain over that array type, in return for
making this code more future-proof.

Noah Misch
2012-01-25 15:28:07 -05:00
Simon Riggs 8366c7803e Allow pg_basebackup from standby node with safety checking.
Base backup follows recommended procedure, plus goes to great
lengths to ensure that partial page writes are avoided.

Jun Ishizuka and Fujii Masao, with minor modifications
2012-01-25 18:02:04 +00:00
Alvaro Herrera 74ab96a45e Add pg_trigger_depth() function
This reports the depth level of triggers currently in execution, or zero
if not called from inside a trigger.

No catversion bump in this patch, but you have to initdb if you want
access to the new function.

Author: Kevin Grittner
2012-01-25 13:22:54 -03:00
Bruce Momjian 6d5aae7afa Now that the shared library name can be adjusted in the library test,
have pg_upgrade allocate a maximum fixed size buffer for testing the
library file name, rather than base the allocation on the library name.

Backpatch to 9.1.
2012-01-25 09:35:17 -05:00
Bruce Momjian a7f2c79a6e Improve plpython fix comment in pg_upgrade. 2012-01-24 22:49:55 -05:00
Bruce Momjian cfe443ab9d In pg_upgrade, when checking for the plpython library, we must check for
"plpython2" when upgrading from pre-PG 9.1.  Patch to head and 9.1.

Per report from Peter.
2012-01-24 22:42:37 -05:00
Bruce Momjian b95aec5290 Fix new SQL tablespace location function usage in pg_upgrade to properly
check cluster version numbers, and fix missing table alias.
2012-01-24 21:51:10 -05:00
Simon Riggs 443b4821f1 Add new replication mode synchronous_commit = 'write'.
Replication occurs only to memory on standby, not to disk,
so provides additional performance if user wishes to
reduce durability level slightly. Adds concept of multiple
independent sync rep queues.

Fujii Masao and Simon Riggs
2012-01-24 20:22:37 +00:00
Peter Eisentraut 89dda5f297 Remove quotes around format_type_be() output
format_type_be() takes care of any needed quoting itself.
2012-01-24 21:49:27 +02:00
Tom Lane f26c9896b3 Suppress variable-clobbered-by-longjmp warning seen with older gcc versions. 2012-01-24 13:44:07 -05:00
Tom Lane beef89567e Suppress possibly-uninitialized-variable warning seen with older gcc versions. 2012-01-24 13:40:26 -05:00
Bruce Momjian 890a9992ce Reduce tab outdent of "error handling" GUC comments in postgresql.conf,
to match surrounding outdenting.
2012-01-24 10:41:00 -05:00
Robert Haas 49562f5eb6 Adjustments to regression tests for security_barrier views.
Drop the role we create, so regression tests pass even when run more
than once against the same cluster, a problem noted by Tom Lane and
Jeff Janes.  Also, rename the temporary role so that it starts with
"regress_", to make it unlikely that we'll collide with an existing
role name while running "make installcheck", per further gripe from
Tom Lane.
2012-01-24 08:46:32 -05:00
Simon Riggs c172b7b02e Resolve timing issue with logging locks for Hot Standby.
We log AccessExclusiveLocks for replay onto standby nodes,
but because of timing issues on ProcArray it is possible to
log a lock that is still held by a just committed transaction
that is very soon to be removed. To avoid any timing issue we
avoid applying locks made by transactions with InvalidXid.

Simon Riggs, bug report Tom Lane, diagnosis Pavan Deolasee
2012-01-23 23:37:32 +00:00
Simon Riggs b8a91d9d1c ALTER <thing> [IF EXISTS] ... allows silent DDL if required,
e.g. ALTER FOREIGN TABLE IF EXISTS foo RENAME TO bar

Pavel Stehule
2012-01-23 23:25:04 +00:00
Magnus Hagander 4993a49b7c Typo fix
Guillaume Lelarge
2012-01-22 22:34:28 +01:00
Peter Eisentraut 95c63b5e32 psql: Add support for tab completion of GRANT/REVOKE role
Previously, only GRANT/REVOKE privilege was supported.

reviewed by Pavel Stehule
2012-01-21 19:46:55 +02:00
Magnus Hagander c14534957b Check number of fields in IDENTIFY_SYSTEM response
Jaime Casanova
2012-01-20 13:57:02 +01:00
Magnus Hagander 356fddfa0f Get rid of itemizedlist inside table
This renders badly on the website, and in this particular case also
doesn't actually add anything to the readability...
2012-01-20 12:30:19 +01:00
Magnus Hagander a65023e7de Further doc cleanups from the pg_stat_activity changes
Fujii Masao
2012-01-20 12:23:26 +01:00
Robert Haas 6e3323d41d Triggered change notifications.
Kevin Grittner, reviewed (in earlier versions) by Álvaro Herrera
2012-01-19 23:15:15 -05:00
Robert Haas c8397bd6d9 Clarify that bgwriter no longer handles checkpoints.
Text by Peter Geoghegan.
2012-01-19 21:53:46 -05:00
Bruce Momjian ecf7a2ea38 Add pg_upgrade C comment about why we check all relkinds for regtypes. 2012-01-19 16:04:34 -05:00
Robert Haas cc53a1e7cc Add bitwise AND, OR, and NOT operators for macaddr data type.
Brendan Jurd, reviewed by Fujii Masao
2012-01-19 15:25:14 -05:00
Magnus Hagander 4f42b546fd Separate state from query string in pg_stat_activity
This separates the state (running/idle/idleintransaction etc) into
it's own field ("state"), and leaves the query field containing just
query text.

The query text will now mean "current query" when a query is running
and "last query" in other states. Accordingly,the field has been
renamed from current_query to query.

Since backwards compatibility was broken anyway to make that, the procpid
field has also been renamed to pid - along with the same field in
pg_stat_replication for consistency.

Scott Mead and Magnus Hagander, review work from Greg Smith
2012-01-19 14:19:20 +01:00
Heikki Linnakangas fa352d662e Make pg_relation_size() and friends return NULL if the object doesn't exist.
That avoids errors when the functions are used in queries like "SELECT
pg_relation_size(oid) FROM pg_class", and a table is dropped concurrently.

Phil Sorber
2012-01-19 13:06:30 +02:00
Peter Eisentraut 6f6b46c9c0 PL/Python: Update example
Change the usesavedplan() example to use a more modern Python style
using the .setdefault() function.
2012-01-18 21:02:09 +02:00
Heikki Linnakangas 326b922e8b Fix corner case in cleanup of transactions using SSI.
When the only remaining active transactions are READ ONLY, we do a "partial
cleanup" of committed transactions because certain types of conflicts
aren't possible anymore. For committed r/w transactions, we release the
SIREAD locks but keep the SERIALIZABLEXACT. However, for committed r/o
transactions, we can go further and release the SERIALIZABLEXACT too. The
problem was with the latter case: we were returning the SERIALIZABLEXACT to
the free list without removing it from the finished list.

The only real change in the patch is the SHMQueueDelete line, but I also
reworked some of the surrounding code to make it obvious that r/o and r/w
transactions are handled differently -- the existing code felt a bit too
clever.

Dan Ports
2012-01-18 17:57:33 +02:00
Magnus Hagander 2106c55ac8 Show psql timing output for failed queries as well as successful ones
This is useful for example when a long-runing statement such as CREATE
INDEX fails after a long time.
2012-01-18 10:34:17 +01:00
Magnus Hagander ae137bcaab Fix warning about unused variable 2012-01-18 10:24:15 +01:00
Robert Haas 504f0c5d5d Regression tests for security_barrier views.
KaiGai Kohei
2012-01-17 22:07:24 -05:00
Robert Haas 4b496a3583 Catch fatal flex errors in the GUC file lexer.
This prevents the postmaster from unexpectedly croaking if postgresql.conf
contains something like:

include 'invalid_directory_name'

Noah Misch. Reviewed by Tom Lane and myself.
2012-01-17 20:51:38 -05:00
Robert Haas 754b8140a1 fastgetattr is in access/htup.h, not access/heapam.h
Noted by Peter Geoghegan
2012-01-16 20:37:01 -05:00
Alvaro Herrera 3b11247aad Disallow merging ONLY constraints in children tables
When creating a child table, or when attaching an existing table as
child of another, we must not allow inheritable constraints to be
merged with non-inheritable ones, because then grandchildren would not
properly get the constraint.  This would violate the grandparent's
expectations.

Bugs noted by Robert Haas.

Author: Nikhil Sontakke
2012-01-16 19:27:05 -03:00
Peter Eisentraut 1b9f774090 psql: Fix memory leak
The command

\password username

leaked memory.
2012-01-16 20:08:33 +02:00
Robert Haas 1575fbcb79 Prevent adding relations to a concurrently dropped schema.
In the previous coding, it was possible for a relation to be created
via CREATE TABLE, CREATE VIEW, CREATE SEQUENCE, CREATE FOREIGN TABLE,
etc.  in a schema while that schema was meanwhile being concurrently
dropped.  This led to a pg_class entry with an invalid relnamespace
value.  The same problem could occur if a relation was moved using
ALTER .. SET SCHEMA while the target schema was being concurrently
dropped.  This patch prevents both of those scenarios by locking the
schema to which the relation is being added using AccessShareLock,
which conflicts with the AccessExclusiveLock taken by DROP.

As a desirable side effect, this also prevents the use of CREATE OR
REPLACE VIEW to queue for an AccessExclusiveLock on a relation on which
you have no rights: that will now fail immediately with a permissions
error, before trying to obtain a lock.

We need similar protection for all other object types, but as everything
other than relations uses a slightly different set of code paths, I'm
leaving that for a separate commit.

Original complaint (as far as I could find) about CREATE by Nikhil
Sontakke; risk for ALTER .. SET SCHEMA pointed out by Tom Lane;
further details by Dan Farina; patch by me; review by Hitoshi Harada.
2012-01-16 09:49:34 -05:00
Andrew Dunstan 01d83ffdca Improve efficiency of recent changes to plperl's sv2cstr().
Along the way, add a missing dependency in the GNUmakefile.

Alex Hunsaker, with a slight adjustment by me.
2012-01-15 16:15:04 -05:00
Heikki Linnakangas b2b4af535e Fix poll() implementation of WaitLatchOrSocket to notice postmaster death.
When the remote end of the pipe is closed, select() reports the fd as
readable, but poll() has a separate POLLHUP return code for that.

Spotted by Peter Geoghegan.
2012-01-15 22:08:03 +02:00