summaryrefslogtreecommitdiff
path: root/src/backend
Commit message (Collapse)AuthorAgeFilesLines
* Modify ShmemInitStruct and ShmemInitHash to throw errors internally,Tom Lane2010-04-2810-105/+86
| | | | | | | | | rather than returning NULL for some-but-not-all failures as they used to. Remove now-redundant tests for NULL from call sites. We had to do something about this because many call sites were failing to check for NULL; and changing it like this seems a lot more useful and mistake-proof than adding checks to the call sites without them.
* Introduce wal_level GUC to explicitly control if information needed forHeikki Linnakangas2010-04-2812-153/+195
| | | | | | | | | | | | | | | | | | | | | | archival or hot standby should be WAL-logged, instead of deducing that from other options like archive_mode. This replaces recovery_connections GUC in the primary, where it now has no effect, but it's still used in the standby to enable/disable hot standby. Remove the WAL-logging of "unlogged operations", like creating an index without WAL-logging and fsyncing it at the end. Instead, we keep a copy of the wal_mode setting and the settings that affect how much shared memory a hot standby server needs to track master transactions (max_connections, max_prepared_xacts, max_locks_per_xact) in pg_control. Whenever the settings change, at server restart, write a WAL record noting the new settings and update pg_control. This allows us to notice the change in those settings in the standby at the right moment, they used to be included in checkpoint records, but that meant that a changed value was not reflected in the standby until the first checkpoint after the change. Bump PG_CONTROL_VERSION and XLOG_PAGE_MAGIC. Whack XLOG_PAGE_MAGIC back to the sequence it used to follow, before hot standby and subsequent patches changed it to 0x9003.
* Modify the built-in text search parser to handle URLs more nearly accordingTom Lane2010-04-281-11/+34
| | | | | | | | | | to RFC 3986. In particular, these characters now terminate the path part of a URL: '"', '<', '>', '\', '^', '`', '{', '|', '}'. The previous behavior was inconsistent and depended on whether a "?" was present in the path. Per gripe from Donald Fraser and spec research by Kevin Grittner. This is a pre-existing bug, but not back-patching since the risks of breaking existing applications seem to outweigh the benefits.
* Fix stupid typo in refnameRangeTblEntry() --- mea maxima culpa.Tom Lane2010-04-281-2/+2
| | | | Per report from Josh.
* Replace the KnownAssignedXids hash table with a sorted-array data structure,Tom Lane2010-04-282-321/+761
| | | | | | | | and be more tense about the locking requirements for it, to improve performance in Hot Standby mode. In passing fix a few bugs and improve a number of comments in the existing HS code. Simon Riggs, with some editorialization by Tom
* If a base backup is cancelled by server shutdown or crash, throw an errorHeikki Linnakangas2010-04-271-1/+11
| | | | | | | in WAL recovery when it sees the shutdown checkpoint record. It's more user-friendly to find out about it at that point than at the end of recovery, and you're not left wondering why your hot standby server never opens up for read-only connections.
* Add missing newlines in WPARSER_TRACE output.Tom Lane2010-04-261-3/+3
|
* Reorder pg_stat_activity columns to be more consistent, using layoutBruce Momjian2010-04-261-6/+6
| | | | | | suggested by Tom Lane. Catalog version bumped due to system view change.
* Add comments about why we set LC_CTYPE in WIN32 for time when we don'tBruce Momjian2010-04-261-2/+10
| | | | actually access it, per information from Hiroshi.
* When we're restricting who can connect, don't allow new walsenders.Robert Haas2010-04-261-21/+32
| | | | | | | | Normal superuser processes are allowed to connect even when the database system is shutting down, or when fewer than superuser_reserved_connection slots remain. This is intended to make sure an administrator can log in and troubleshoot, so don't extend these same courtesies to users connecting for replication.
* Add C comments for recent to_char('L') fix for Win32.Bruce Momjian2010-04-241-23/+55
|
* Patch revoked because of objections.Simon Riggs2010-04-241-16/+1
|
* Fix various instances of "the the".Robert Haas2010-04-233-7/+7
| | | | Two of these were pointed out by Erik Rijkers; the rest I found.
* Add missing optimizer hooks for function cost and number of rows.Simon Riggs2010-04-231-1/+16
| | | | | Closely follow design of other optimizer hooks: if hook exists retrieve value from plugin; if still not set then get from cache.
* Previous patch revoked following objections.Simon Riggs2010-04-231-14/+3
|
* Make CheckRequiredParameterValues() depend upon correct combinationSimon Riggs2010-04-231-3/+14
| | | | | | | of parameters. Fix bug report by Robert Haas that error message and hint was incorrect if wrong mode parameters specified on master. Internal changes only. Proposals for parameter simplification on master/primary still under way.
* Fix message punctuationPeter Eisentraut2010-04-221-2/+2
|
* Optimise btree delete processing when no active backends.Simon Riggs2010-04-223-23/+22
| | | | | Clarify comments, downgrade a message to DEBUG and remove some debug counters. Direct from ideas by Heikki Linnakangas.
* Further reductions in Hot Standby conflict processing. TheseSimon Riggs2010-04-223-11/+14
| | | | | | | | | come from the realistion that HEAP2_CLEAN records don't always remove user visible data, so conflict processing for them can be skipped. Confirm validity using Assert checks, clarify circumstances under which we log heap_cleanup_info records. Tuning arises from bug fixing of earlier safety check failures.
* Fix encoding issue when lc_monetary or lc_numeric are different encodingItagaki Takahiro2010-04-221-13/+72
| | | | | | | | | from lc_ctype, that could happen on Windows. We need to change lc_ctype together with lc_monetary or lc_numeric, and convert strings in lconv from lc_ctype encoding to the database encoding. The bug reported by Mikko, original patch by Hiroshi Inoue, with changes by Bruce and me.
* Enforce superuser permissions checks during ALTER ROLE/DATABASE SET, ratherTom Lane2010-04-211-42/+131
| | | | | | | | | | | | than during define_custom_variable(). This entails rejecting an ALTER command if the target variable doesn't have a known (non-placeholder) definition, unless the calling user is superuser. When the variable *is* known, we can correctly apply the rule that only superusers can issue ALTER for SUSET parameters. This allows define_custom_variable to apply ALTER's values for SUSET parameters at module load time, secure in the knowledge that only a superuser could have set the ALTER value. This change fixes a longstanding gotcha in the usage of SUSET-level custom parameters; which is a good thing to fix now that plpgsql defines such a parameter.
* Only send cleanup_info messages if VACUUM removes any tuples.Simon Riggs2010-04-211-3/+6
| | | | | | | There is no other purpose for this message type than to report the latestRemovedXid of removed tuples, prior to index scans. Removes overlooked path for sending invalid latestRemovedXid. Fixes buildfarm failure on centaur.
* Relax locking during GetCurrentVirtualXIDs(). Earlier improvementsSimon Riggs2010-04-212-63/+40
| | | | | | | | | | to handling of btree delete records mean that all snapshot conflicts on standby now have a valid, useful latestRemovedXid. Our earlier approach using LW_EXCLUSIVE was useful when we didnt always have a valid value, though is no longer useful or necessary. Asserts added to code path to prove and ensure this is the case. This will reduce contention and improve performance of larger Hot Standby servers.
* Fix oversight in collecting values for cleanup_info records.Simon Riggs2010-04-212-11/+23
| | | | | | | vacuum_log_cleanup_info() now generates log records with a valid latestRemovedXid set in all cases. Also be careful not to zero the value when we do a round of vacuuming part-way through lazy_scan_heap(). Incidentally, this reduces frequency of conflicts in Hot Standby.
* Fix pg_hba.conf matching so that replication connections only match recordsTom Lane2010-04-213-38/+88
| | | | | | | | | with database = replication. The previous coding would allow them to match ordinary records too, but that seems like a recipe for security breaches. Improve the messages associated with no-such-pg_hba.conf entry to report replication connections as such, since that's now a critical aspect of whether the connection matches. Make some cursory improvements in the related documentation, too.
* Move the check for whether walreceiver has authenticated as a superuserTom Lane2010-04-212-8/+8
| | | | | from walsender.c, where it didn't really belong, to postinit.c where it does belong (and is essentially free, too).
* Arrange for client authentication to occur before we select a specificTom Lane2010-04-206-112/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | database to connect to. This is necessary for the walsender code to work properly (it was previously using an untenable assumption that template1 would always be available to connect to). This also gets rid of a small security shortcoming that was introduced in the original patch to eliminate the flat authentication files: before, you could find out whether or not the requested database existed even if you couldn't pass the authentication checks. The changes needed to support this are mainly just to treat pg_authid and pg_auth_members as nailed relations, so that we can read them without having to be able to locate real pg_class entries for them. This mechanism was already debugged for pg_database, but we hadn't recognized the value of applying it to those catalogs too. Since the current code doesn't have support for accessing toast tables before we've brought up all of the relcache, remove pg_authid's toast table to ensure that no one can store an out-of-line toasted value of rolpassword. The case seems quite unlikely to occur in practice, and was effectively unsupported anyway in the old "flatfiles" implementation. Update genbki.pl to actually implement the same rules as bootstrap.c does for not-nullability of catalog columns. The previous coding was a bit cheesy but worked all right for the previous set of bootstrap catalogs. It does not work for pg_authid, where rolvaliduntil needs to be nullable. Initdb forced due to minor catalog changes (mainly the toast table removal).
* Fix code that doesn't work on machines with strict alignment requirements:Tom Lane2010-04-201-32/+33
| | | | | | | must use memcpy here rather than struct assignment. In passing, rearrange some randomly-ordered declarations to be a tad less random.
* Rename standby_keep_segments to wal_keep_segments.Robert Haas2010-04-203-10/+10
| | | | | | Also, make the name of the GUC and the name of the backing variable match. Alnong the way, clean up a couple of slight typographical errors in the related docs.
* Move the responsibility for calling StartupXLOG into InitPostgres, forTom Lane2010-04-203-44/+34
| | | | | | | | | | | | | those process types that go through InitPostgres; in particular, bootstrap and standalone-backend cases. This ensures that we have set up a PGPROC and done some other basic initialization steps (corresponding to the if (IsUnderPostmaster) block in AuxiliaryProcessMain) before we attempt to run WAL recovery in a standalone backend. As was discovered last September, this is necessary for some corner-case code paths during WAL recovery, particularly end-of-WAL cleanup. Moving the bootstrap case here too is not necessary for correctness, but it seems like a good idea since it reduces the number of distinct code paths.
* Add new message for explicit rejection by pg_hba.conf. ImplicitSimon Riggs2010-04-192-9/+40
| | | | rejection retains same message as before.
* Check RecoveryInProgress() while holding ProcArrayLock during snapshots.Simon Riggs2010-04-191-4/+9
| | | | | This prevents a rare, yet possible race condition at the exact moment of transition from recovery to normal running.
* Fix uninitialized local variables. Not sure why gcc doesn't complain aboutTom Lane2010-04-191-4/+3
| | | | | these --- maybe because they're effectively unused? MSVC does complain though, per buildfarm.
* Add wrapper function libpqrcv_PQexec() in the walreceiver that uses asyncMagnus Hagander2010-04-192-6/+88
| | | | | | | | libpq to send queries, making the waiting for responses interruptible on platforms where PQexec() can't normally be interrupted by signals, such as win32. Fujii Masao and Magnus Hagander
* Add an 'enable_material' GUC.Robert Haas2010-04-195-12/+36
| | | | | | | | | | | The logic for determining whether to materialize has been significantly overhauled for 9.0. In case there should be any doubt about whether materialization is a win in any particular case, this should provide a convenient way of seeing what happens without it; but even with enable_material turned off, we still materialize in cases where it is required for correctness. Thanks to Tom Lane for the review.
* Improve sequence and sense of messages from pg_stop_backup().Simon Riggs2010-04-181-4/+12
| | | | | | | | | | | Now doesn't report it is waiting until it actually is waiting, plus message doesn't appear until at least 5 seconds wait, so we avoid reporting the wait before we've given the archiver a reasonable time to wake up and archive the file we just created earlier in the function. Also add new unconditional message to confirm safe completion. Now a normal, healthy execution does not report waiting at all, just safe completion.
* Remove some additional changes in previous commit that belong elsewhere.Simon Riggs2010-04-181-7/+1
|
* Tune GetSnapshotData() during Hot Standby by avoiding loopSimon Riggs2010-04-182-70/+77
| | | | | | | through normal backends. Makes code clearer also, since we avoid various Assert()s. Performance of snapshots taken during recovery no longer depends upon number of read-only backends.
* On Windows, syslogger runs in two threads. The main thread processes configHeikki Linnakangas2010-04-161-33/+28
| | | | | | | | reload and rotation signals, and a helper thread reads messages from the pipe and writes them to the log file. However, server code isn't generally thread-safe, so if both try to do e.g palloc()/pfree() at the same time, bad things will happen. To fix that, use a critical section (which is like a mutex) to enforce that only one the threads are active at a time.
* In standby mode, suppress repeated LOG messages about a corrupt record,Heikki Linnakangas2010-04-161-36/+54
| | | | | which just indicates that we've reached the end of valid WAL found in the standby.
* Update XML features listPeter Eisentraut2010-04-151-1/+2
|
* Doc change: effect -> affect, per Robert HaasBruce Momjian2010-04-151-2/+2
|
* Fix a problem introduced by my patch of 2010-01-12 that revised the wayTom Lane2010-04-141-13/+31
| | | | | | | | | | | | | | | | | | | | | relcache reload works. In the patched code, a relcache entry in process of being rebuilt doesn't get unhooked from the relcache hash table; which means that if a cache flush occurs due to sinval queue overrun while we're rebuilding it, the entry could get blown away by RelationCacheInvalidate, resulting in crash or misbehavior. Fix by ensuring that an entry being rebuilt has positive refcount, so it won't be seen as a target for removal if a cache flush occurs. (This will mean that the entry gets rebuilt twice in such a scenario, but that's okay.) It appears that the problem can only arise within a transaction that has previously reassigned the relfilenode of a pre-existing table, via TRUNCATE or a similar operation. Per bug #5412 from Rusty Conover. Back-patch to 8.2, same as the patch that introduced the problem. I think that the failure can't actually occur in 8.2, since it lacks the rd_newRelfilenodeSubid optimization, but let's make it work like the later branches anyway. Patch by Heikki, slightly editorialized on by me.
* Typo fix. Kevin Grittner.Robert Haas2010-04-141-2/+2
|
* Fix minor typo in comment in xlog.cSimon Riggs2010-04-141-2/+2
|
* Allow Hot Standby to begin from a shutdown checkpoint.Heikki Linnakangas2010-04-132-61/+222
| | | | Patch by Simon Riggs & me
* Only try to do a graceful disconnect if we've successfully loaded theMagnus Hagander2010-04-131-2/+3
| | | | | | | shared library with the disconnect function in it. Fixes segmentation fault reported by Jeff Davis. Fujii Masao
* Update the location of last removed WAL segment in shared memory onlyHeikki Linnakangas2010-04-121-14/+31
| | | | | | | after actually removing one, so that if we can't remove segments because WAL archiving is lagging behind, we don't unnecessarily forbid streaming the old not-yet-archived segments that are still perfectly valid. Per suggestion from Fujii Masao.
* Need to use the start pointer of a block we read from WAL segment inHeikki Linnakangas2010-04-121-3/+4
| | | | the calculation, not the end pointer, as pointed out by Fujii Masao.
* Change the logic to decide when to delete old WAL segments, so that itHeikki Linnakangas2010-04-124-29/+135
| | | | | | | | | | doesn't take into account how far the WAL senders are. This way a hung WAL sender doesn't prevent old WAL segments from being recycled/removed in the primary, ultimately causing the disk to fill up. Instead add standby_keep_segments setting to control how many old WAL segments are kept in the primary. This also makes it more reliable to use streaming replication without WAL archiving, assuming that you set standby_keep_segments high enough.