summaryrefslogtreecommitdiff
path: root/src/backend
AgeCommit message (Collapse)Author
2011-02-09Fix allocation of RW-conflict pool in the new predicate lock manager, andHeikki Linnakangas
also take the RW-conflict pool into account in the PredicateLockShmemSize() estimate.
2011-02-09Implement NOWAIT option for BASE_BACKUP commandMagnus Hagander
Specifying this option makes the server not wait for the xlog to be archived, or emit a warning that it can't, instead leaving the responsibility with the client. This is useful when the log is being streamed using the streaming protocol in parallel with the backup, without having log archiving enabled.
2011-02-08Suppress some compiler warnings in recent commits.Tom Lane
Older versions of gcc tend to throw "variable might be clobbered by `longjmp' or `vfork'" warnings whenever a variable is assigned in more than one place and then used after the end of a PG_TRY block. That's reasonably easy to work around in execute_extension_script, and the overhead of unconditionally saving/restoring the GUC variables seems unlikely to be a serious concern. Also clean up logic in ATExecValidateConstraint to make it easier to read and less likely to provoke "variable might be used uninitialized in this function" warnings.
2011-02-08Core support for "extensions", which are packages of SQL objects.Tom Lane
This patch adds the server infrastructure to support extensions. There is still one significant loose end, namely how to make it play nice with pg_upgrade, so I am not yet committing the changes that would make all the contrib modules depend on this feature. In passing, fix a disturbingly large amount of breakage in AlterObjectNamespace() and callers. Dimitri Fontaine, reviewed by Anssi Kääriäinen, Itagaki Takahiro, Tom Lane, and numerous others
2011-02-08Per-column collation supportPeter Eisentraut
This adds collation support for columns and domains, a COLLATE clause to override it per expression, and B-tree index support. Peter Eisentraut reviewed by Pavel Stehule, Itagaki Takahiro, Robert Haas, Noah Misch
2011-02-08Named restore points in recovery. Users can record named points, thenSimon Riggs
new recovery.conf parameter recovery_target_name allows PITR to specify named points as recovery targets. Jaime Casanova, reviewed by Euler Taveira de Oliveira, plus minor edits
2011-02-08Basic Recovery Control functions for use in Hot Standby. Pause, Resume,Simon Riggs
Status check functions only. Also, new recovery.conf parameter to pause_at_recovery_target, default on. Simon Riggs, reviewed by Fujii Masao
2011-02-08Remove rare corner case for data loss when triggering standby server.Simon Riggs
If the standby was streaming when trigger file arrives, check also in the archive for additional WAL files. This is a corner case since it is unlikely that we would trigger a failover while the master is still available and sending data to standby, while at the same time running in archive mode and also while the streaming standby has fallen behind archive. Someone would eventually be unlucky; we must plug all gaps however small. Fujii Masao
2011-02-08Extend ALTER TABLE to allow Foreign Keys to be added without initial validation.Simon Riggs
FK constraints that are marked NOT VALID may later be VALIDATED, which uses an ShareUpdateExclusiveLock on constraint table and RowShareLock on referenced table. Significantly reduces lock strength and duration when adding FKs. New state visible from psql. Simon Riggs, with reviews from Marko Tiikkaja and Robert Haas
2011-02-08Fix copy-pasto in description of pg_serial, and silence compiler warningHeikki Linnakangas
about uninitialized field you get on some compilers.
2011-02-07Avoid having autovacuum workers wait for relation locks.Robert Haas
Waiting for relation locks can lead to starvation - it pins down an autovacuum worker for as long as the lock is held. But if we're doing an anti-wraparound vacuum, then we still wait; maintenance can no longer be put off. To assist with troubleshooting, if log_autovacuum_min_duration >= 0, we log whenever an autovacuum or autoanalyze is skipped for this reason. Per a gripe by Josh Berkus, and ensuing discussion.
2011-02-08Implement genuine serializable isolation level.Heikki Linnakangas
Until now, our Serializable mode has in fact been what's called Snapshot Isolation, which allows some anomalies that could not occur in any serialized ordering of the transactions. This patch fixes that using a method called Serializable Snapshot Isolation, based on research papers by Michael J. Cahill (see README-SSI for full references). In Serializable Snapshot Isolation, transactions run like they do in Snapshot Isolation, but a predicate lock manager observes the reads and writes performed and aborts transactions if it detects that an anomaly might occur. This method produces some false positives, ie. it sometimes aborts transactions even though there is no anomaly. To track reads we implement predicate locking, see storage/lmgr/predicate.c. Whenever a tuple is read, a predicate lock is acquired on the tuple. Shared memory is finite, so when a transaction takes many tuple-level locks on a page, the locks are promoted to a single page-level lock, and further to a single relation level lock if necessary. To lock key values with no matching tuple, a sequential scan always takes a relation-level lock, and an index scan acquires a page-level lock that covers the search key, whether or not there are any matching keys at the moment. A predicate lock doesn't conflict with any regular locks or with another predicate locks in the normal sense. They're only used by the predicate lock manager to detect the danger of anomalies. Only serializable transactions participate in predicate locking, so there should be no extra overhead for for other transactions. Predicate locks can't be released at commit, but must be remembered until all the transactions that overlapped with it have completed. That means that we need to remember an unbounded amount of predicate locks, so we apply a lossy but conservative method of tracking locks for committed transactions. If we run short of shared memory, we overflow to a new "pg_serial" SLRU pool. We don't currently allow Serializable transactions in Hot Standby mode. That would be hard, because even read-only transactions can cause anomalies that wouldn't otherwise occur. Serializable isolation mode now means the new fully serializable level. Repeatable Read gives you the old Snapshot Isolation level that we have always had. Kevin Grittner and Dan Ports, reviewed by Jeff Davis, Heikki Linnakangas and Anssi Kääriäinen
2011-02-07Fix a comment for MergeAttributes.Itagaki Takahiro
We forgot to adjust it when we changed relistemp to relpersistence.
2011-02-07Fix error messages for FreeFile in COPY command.Itagaki Takahiro
They are extracted from COPY API patch. suggested by Noah Misch
2011-02-06Rename macro DECIMAL to DECIMAL_T to help pgindent; this is alreadyBruce Momjian
done for a few other macros in that file, for other reasons. I also remove pgindent/README mention of the file.
2011-02-06IDENTIFY_SYSTEM now returns 3 fields, not 2Magnus Hagander
2011-02-06Tighten ALTER FOREIGN TABLE .. SET DATA TYPE checks.Robert Haas
If the foreign table's rowtype is being used as the type of a column in another table, we can't just up and change its data type. This was already checked for composite types and ordinary tables, but we previously failed to enforce it for foreign tables.
2011-02-04Add C comment about why older compilers complain about basebackup.c'sBruce Momjian
longjump.
2011-02-04Clarify comment in ATRewriteTable().Robert Haas
Make sure it's clear that the prohibition on adding a column with a default when the rowtype is used elsewhere is intentional, and be a bit more explicit about the other cases where we perform this check.
2011-02-04Move pipe.c into the backend.Robert Haas
It's full of backend-specific error reporting, so it's neither possible nor necessary for this to be used from frontend code.
2011-02-04Make handling of errcodes.h more consistent with other generated headers.Robert Haas
This fixes make distprep, and seems more robust in other ways as well. Some special handling is required because errcodes.txt is needed by some stuff in src/port, but just by src/backend as is the case for the other generated headers. While I'm at it, fix a few other things that were overlooked in the original patch.
2011-02-04Unbreak the VPATH build.Robert Haas
My commit ddfe26f6441c24660595c5efe5fd0bd3974cdc5c of 2010-02-03 broke it. Per buildfarm.
2011-02-03Preserve copyright notice from old errcodes.h file.Robert Haas
2011-02-03Avoid maintaining three separate copies of the error codes list.Robert Haas
src/pl/plpgsql/src/plerrcodes.h, src/include/utils/errcodes.h, and a big chunk of errcodes.sgml are now automatically generated from a single file, src/backend/utils/errcodes.txt. Jan Urbański, reviewed by Tom Lane.
2011-02-03Include more status information in walsender resultsMagnus Hagander
Add the current xlog insert location to the response of IDENTIFY_SYSTEM, and adds result sets containing start and stop location of backups to BASE_BACKUP responses.
2011-02-02Rename function to first_path_var_separator() to clarify it works withBruce Momjian
path variables, not directory paths.
2011-02-02Log restartpoints in the same fashion as checkpoints.Robert Haas
Prior to 9.0, restartpoints never created, deleted, or recycled WAL files, but now they can. This code makes log_checkpoints treat checkpoints and restartpoints symmetrically. It also adjusts up the documentation of the parameter to mention restartpoints. Fujii Masao. Docs by me, as suggested by Itagaki Takahiro.
2011-02-01Re-classify ERRCODE_DATABASE_DROPPED to 57P04Simon Riggs
2011-02-01Fix wrong error reports in 'number of array dimensions exceeds theItagaki Takahiro
maximum allowed' messages, that have reported one-less dimensions. Alexey Klyukin
2011-02-01Create new errcode for recovery conflict caused by db drop on master.Simon Riggs
Previously reported as ERRCODE_ADMIN_SHUTDOWN, this case is now reported as ERRCODE_T_R_DATABASE_DROPPED. No message text change. Unlikely to happen on most servers, so low impact change to allow session poolers to correctly handle this situation. Tatsuo Ishii, edits by me, review by Robert Haas
2011-01-31Fix error code for canceling statement due to conflict with recovery.Simon Riggs
All retryable conflict errors now have an error code that indicates that a retry is possible, correcting my incomplete fix of 2010/05/12 Tatsuo Ishii and Simon Riggs, input from Robert Haas and Florian Pflug
2011-01-31Support multiple concurrent pg_basebackup backups.Heikki Linnakangas
With this patch, pg_basebackup doesn't write a backup_label file in the data directory, so it doesn't interfere with a pg_start/stop_backup() based backup anymore. backup_label is still included in the backup, but it is injected directly into the tar stream. Heikki Linnakangas, reviewed by Fujii Masao and Magnus Hagander.
2011-01-30Make reduce_outer_joins() smarter about semijoins.Tom Lane
reduce_outer_joins() mistakenly treated a semijoin like a left join for purposes of deciding whether not-null constraints created by the join's quals could be passed down into the join's left-hand side (possibly resulting in outer-join simplification there). Actually, semijoin works like inner join for this purpose, ie, we do not need to see any rows that can't possibly satisfy the quals. Hence, two-line fix to treat semi and inner joins alike. Per observation by Andres Freund about a performance gripe from Yazan Suleiman. Back-patch to 8.4, since this oversight has been there since the current handling of semijoins was implemented.
2011-01-30Add option to include WAL in base backupMagnus Hagander
When included, this makes the base backup a complete working "clone" of the initial database, ready to have a postmaster started against it without the need to set up any log archiving or similar. Magnus Hagander, reviewed by Fujii Masao and Heikki Linnakangas
2011-01-29Try to avoid running with a full fsync request queue.Robert Haas
When we need to insert a new entry and the queue is full, compact the entire queue in the hopes of making room for the new entry. Doing this on every insertion might worsen contention on BgWriterCommLock, but when the queue it's full, it's far better than allowing the backend to perform its own fsync, per testing by Greg Smith as reported in http://archives.postgresql.org/pgsql-hackers/2011-01/msg02665.php Original idea from Greg Smith. Patch by me. Review by Chris Browne and Greg Smith
2011-01-27Don't include <asm/ia64regs.h> unnecessarily.Tom Lane
We only need that header when compiling with icc, since the gcc variant of ia64_get_bsp() uses in-line assembly code. Per report from Frank Brendel, the header doesn't exist on all IA64 platforms; so don't include it unless we need it.
2011-01-27Restore ALTER TABLE .. ADD COLUMN w/DEFAULT restriction.Robert Haas
This reverts commit a06e41deebdf74b8b5109329dc75b2e9d9057962 of 2011-01-26. Per discussion, this behavior is not wanted, as it would need to change if we ever made composite types support DEFAULT.
2011-01-26Change inv_truncate() to not repeat its systable_getnext_ordered() scan.Tom Lane
In the case where the initial call of systable_getnext_ordered() returned NULL, this function would nonetheless call it again. That's undefined behavior that only by chance failed to not give visibly incorrect results. Put an if-test around the final loop to prevent that, and in passing improve some comments. No back-patch since there's no actual failure. Per report from YAMAMOTO Takashi.
2011-01-26Add a comment explaining why we force physical removal of OIDs.Robert Haas
Noah Misch, slightly revised.
2011-01-26Remove arbitrary ALTER TABLE .. ADD COLUMN restriction.Robert Haas
The previous coding prevented ALTER TABLE .. ADD COLUMN from being used with a non-NULL default in situations where the table's rowtype was being used elsewhere. But this is a completely arbitrary restriction since you could do the same operation in multiple steps (add the column, add the default, update the table). Inspired by a patch from Noah Misch, though I didn't use his code.
2011-01-25Replace pg_class.relhasexclusion with pg_index.indisexclusion.Tom Lane
There isn't any need to track this state on a table-wide basis, and trying to do so introduces undesirable semantic fuzziness. Move the flag to pg_index, where it clearly describes just a single index and can be immutable after index creation.
2011-01-25Implement ALTER TABLE ADD UNIQUE/PRIMARY KEY USING INDEX.Tom Lane
This feature allows a unique or pkey constraint to be created using an already-existing unique index. While the constraint isn't very functionally different from the bare index, it's nice to be able to do that for documentation purposes. The main advantage over just issuing a plain ALTER TABLE ADD UNIQUE/PRIMARY KEY is that the index can be created with CREATE INDEX CONCURRENTLY, so that there is not a long interval where the table is locked against updates. On the way, refactor some of the code in DefineIndex() and index_create() so that we don't have to pass through those functions in order to create the index constraint's catalog entries. Also, in parse_utilcmd.c, pass around the ParseState pointer in struct CreateStmtContext to save on notation, and add error location pointers to some error reports that didn't have one before. Gurjeet Singh, reviewed by Steve Singer and Tom Lane
2011-01-25Typo fix for MemSet size.Magnus Hagander
Fujii Masao
2011-01-23Make walsender options order-independentMagnus Hagander
While doing this, also move base backup options into a struct instead of increasing the number of parameters to multiple functions for each new option.
2011-01-23Improve getObjectDescription's display of pg_amop and pg_amproc entries.Tom Lane
Include the lefttype/righttype columns explicitly (instead of assuming the reader can deduce them from the operator or function description), and move the operator or function description to the end of the string, to make it clearer that it's a referenced object and not the amop or amproc item itself. Per extensive discussion of Andreas Karlsson's original patch. Andreas Karlsson, Tom Lane
2011-01-23Only show pg_stat_replication details to superusersMagnus Hagander
2011-01-23Add pg_basebackup tool for streaming base backupsMagnus Hagander
This tool makes it possible to do the pg_start_backup/ copy files/pg_stop_backup step in a single command. There are still some steps to be done before this is a complete backup solution, such as the ability to stream the required WAL logs, but it's still usable, and could do with some buildfarm coverage. In passing, make the checkpoint request optionally fast instead of hardcoding it. Magnus Hagander, reviewed by Fujii Masao and Dimitri Fontaine
2011-01-22Code cleanup for assign_transaction_read_only.Robert Haas
As in commit fb4c5d2798730f60b102d775f22fb53c26a6445d on 2011-01-21, this avoids spurious debug messages and allows idempotent changes at any time. Along the way, make assign_XactIsoLevel allow idempotent changes even when not within a subtransaction, to be consistent with the new coding of assign_transaction_read_only and because there's no compelling reason to do otherwise. Kevin Grittner, with some adjustments.
2011-01-22Allow the wal_buffers setting to be auto-tuned to a reasonable value.Tom Lane
If wal_buffers is initially set to -1 (which is now the default), it's replaced by 1/32nd of shared_buffers, with a minimum of 8 (the old default) and a maximum of the XLOG segment size. The allowed range for manual settings is still from 4 up to whatever will fit in shared memory. Greg Smith, with implementation correction by me.
2011-01-21Avoid treating WAL senders as normal backends.Robert Haas
The previous coding treated anything that wasn't an autovacuum launcher as a normal backend, which is wrong now that we also have WAL senders. Fujii Masao, reviewed by Robert Haas, Alvaro Herrera, Tom Lane, and Bernd Helmle.