summaryrefslogtreecommitdiff
path: root/src/backend/utils/init
AgeCommit message (Collapse)Author
2008-09-11Initialize the minimum frozen Xid in vac_update_datfrozenxid usingAlvaro Herrera
GetOldestXmin() instead of RecentGlobalXmin; this is safer because we do not depend on the latter being correctly set elsewhere, and while it is more expensive, this code path is not performance-critical. This is a real risk for autovacuum, because it can execute whole cycles without doing a single vacuum, which would mean that RecentGlobalXmin would stay at its initialization value, FirstNormalTransactionId, causing a bogus value to be inserted in pg_database. This bug could explain some recent reports of failure to truncate pg_clog. At the same time, change the initialization of RecentGlobalXmin to InvalidTransactionId, and ensure that it's set to something else whenever it's going to be used. Using it as FirstNormalTransactionId in HOT page pruning could incur in data loss. InitPostgres takes care of setting it to a valid value, but the extra checks are there to prevent "special" backends from behaving in unusual ways. Per Tom Lane's detailed problem dissection in 29544.1221061979@sss.pgh.pa.us
2008-01-03Make standard maintenance operations (including VACUUM, ANALYZE, REINDEX,Tom Lane
and CLUSTER) execute as the table owner rather than the calling user, using the same privilege-switching mechanism already used for SECURITY DEFINER functions. The purpose of this change is to ensure that user-defined functions used in index definitions cannot acquire the privileges of a superuser account that is performing routine maintenance. While a function used in an index is supposed to be IMMUTABLE and thus not able to do anything very interesting, there are several easy ways around that restriction; and even if we could plug them all, there would remain a risk of reading sensitive information and broadcasting it through a covert channel such as CPU usage. To prevent bypassing this security measure, execution of SET SESSION AUTHORIZATION and SET ROLE is now forbidden within a SECURITY DEFINER context. Thanks to Itagaki Takahiro for reporting this vulnerability. Security: CVE-2007-6600
2006-11-05Fix recently-identified PITR recovery hazard: the base backup could containTom Lane
stale relcache init files (pg_internal.init), and there is no mechanism for updating them during WAL replay. Easiest solution is just to delete the init files at conclusion of startup, and let the first backend started in each database take care of rebuilding the init file. Simon Riggs and Tom Lane. Back-patched to 8.1. Arguably this should be fixed in 8.0 too, but it would require significantly more code since 8.0 has no handy startup-time scan of pg_database to piggyback on. Manual solution of the problem is possible in 8.0 (just delete the pg_internal.init files before starting WAL replay), so that may be a sufficient answer.
2006-11-05Fix recently-understood problems with handling of XID freezing, particularlyTom Lane
in PITR scenarios. We now WAL-log the replacement of old XIDs with FrozenTransactionId, so that such replacement is guaranteed to propagate to PITR slave databases. Also, rather than relying on hint-bit updates to be preserved, pg_clog is not truncated until all instances of an XID are known to have been replaced by FrozenTransactionId. Add new GUC variables and pg_autovacuum columns to allow management of the freezing policy, so that users can trade off the size of pg_clog against the amount of freezing work done. Revise the already-existing code that forces autovacuum of tables approaching the wraparound point to make it more bulletproof; also, revise the autovacuum logic so that anti-wraparound vacuuming is done per-table rather than per-database. initdb forced because of changes in pg_class, pg_database, and pg_autovacuum catalogs. Heikki Linnakangas, Simon Riggs, and Tom Lane.
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-09-18Add built-in userlock manipulation functions to replace the formerTom Lane
contrib functionality. Along the way, remove the USER_LOCKS configuration symbol, since it no longer makes any sense to try to compile that out. No user documentation yet ... mmoncure has promised to write some. Thanks to Abhijit Menon-Sen for creating a first draft to work from.
2006-08-16Seems some C compilers think 'restrict' is a fully reserved word.Tom Lane
Per buildfarm results from warthog.
2006-08-15Add server support for "plugin" libraries that can be used for add-on tasksTom Lane
such as debugging and performance measurement. This consists of two features: a table of "rendezvous variables" that allows separately-loaded shared libraries to communicate, and a new GUC setting "local_preload_libraries" that allows libraries to be loaded into specific sessions without explicit cooperation from the client application. To make local_preload_libraries as flexible as possible, we do not restrict its use to superusers; instead, it is restricted to load only libraries stored in $libdir/plugins/. The existing LOAD command has also been modified to allow non-superusers to LOAD libraries stored in this directory. This patch also renames the existing GUC variable preload_libraries to shared_preload_libraries (after a suggestion by Simon Riggs) and does some code refactoring in dfmgr.c to improve clarity. Korry Douglas, with a little help from Tom Lane.
2006-08-08Add a feature for automatic initialization and finalization of dynamicallyTom Lane
loaded libraries: call functions _PG_init() and _PG_fini() if the library defines such symbols. Hence we no longer need to specify an initialization function in preload_libraries: we can assume that the library used the _PG_init() convention, instead. This removes one source of pilot error in use of preloaded libraries. Original patch by Ralf Engelschall, preload_libraries changes by me.
2006-07-14Remove 576 references of include files that were not needed.Bruce Momjian
2006-07-13Allow include files to compile own their own.Bruce Momjian
Strip unused include files out unused include files, and add needed includes to C files. The next step is to remove unused include files in C files.
2006-07-10Improve vacuum code to track minimum Xids per table instead of per database.Alvaro Herrera
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.
2006-06-22Standalone backends need pgstat_bestart() too, per Qingqing Zhou.Tom Lane
2006-05-04Simplify relcache startup sequence. With the new design of InitPostgresTom Lane
it's not necessary to have three separate calls anymore. This patch also fixes things so we don't try to read pg_internal.init until after we've obtained lock on the target database; which was fairly harmless, but it's certainly cleaner this way.
2006-05-04Rethink the locking mechanisms used for CREATE/DROP/RENAME DATABASE.Tom Lane
The former approach used ExclusiveLock on pg_database, which being a cluster-wide lock meant only one of these operations could proceed at a time; worse, it also blocked all incoming connections in ReverifyMyDatabase. Now that we have LockSharedObject(), we can use locks of different types applied to databases considered as objects. This allows much more flexible management of the interlocking: two CREATE DATABASEs need not block each other, and need not block connections except to the template database being used. Similarly DROP DATABASE doesn't block unrelated operations. The locking used in flatfiles.c is also much narrower in scope than before. Per recent proposal.
2006-05-03Create a syscache for pg_database-indexed-by-oid, and make use of itTom Lane
in various places that were previously doing ad hoc pg_database searches. This may speed up database-related privilege checks a little bit, but the main motivation is to eliminate the performance reason for having ReverifyMyDatabase do such a lot of stuff (viz, avoiding repeat scans of pg_database during backend startup). The locking reason for having that routine is about to go away, and it'd be good to have the option to break it up.
2006-05-02GIN: Generalized Inverted iNdex.Teodor Sigaev
text[], int4[], Tsearch2 support for GIN.
2006-04-30Code review for GRANT CONNECT patch. Spell the privilege as CONNECT notTom Lane
CONNECTION, fix a number of places that were missed (eg pg_dump support), avoid executing an extra search of pg_database during startup.
2006-04-30Add GRANT CONNECTION ON DATABASE, to be used in addition to pg_hba.conf.Bruce Momjian
Gevik Babakhani
2006-03-29Clean up and document the API for XLogOpenRelation and XLogReadBuffer.Tom Lane
This commit doesn't make much functional change, but it does eliminate some duplicated code --- for instance, PageIsNew tests are now done inside XLogReadBuffer rather than by each caller. The GIST xlog code still needs a lot of love, but I'll worry about that separately.
2006-03-05Update copyright for 2006. Update scripts.Bruce Momjian
2006-01-05Make all command-line options of postmaster and postgres the same. SeePeter Eisentraut
http://archives.postgresql.org/pgsql-hackers/2006-01/msg00151.php for the complete plan.
2006-01-05Remove BEOS port.Bruce Momjian
2006-01-04Rearrange backend startup sequence so that ShmemIndexLock can becomeTom Lane
an LWLock instead of a spinlock. This hardly matters on Unix machines but should improve startup performance on Windows (or any port using EXEC_BACKEND). Per previous discussion.
2005-11-22Re-run pgindent, fixing a problem where comment lines after a blankBruce Momjian
comment line where output as too long, and update typedefs for /lib directory. Also fix case where identifiers were used as variable names in the backend, but as typedefs in ecpg (favor the backend for indenting). Backpatch to 8.1.X.
2005-10-15Standard pgindent run for 8.1.Bruce Momjian
2005-08-17Avoid an Assert failure if OuterUserId hasn't been set yet duringTom Lane
AbortTransaction. This can happen if a backend's InitPostgres transaction fails (eg, because the given username is invalid). Per Alvaro.
2005-08-11Autovacuum loose end mop-up. Provide autovacuum-specific vacuum costTom Lane
delay and limit, both as global GUCs and as table-specific entries in pg_autovacuum. stats_reset_on_server_start is now OFF by default, but a reset is forced if we did WAL replay. XID-wrap vacuums do not ANALYZE, but do FREEZE if it's a template database. Alvaro Herrera
2005-08-08Cause ShutdownPostgres to do a normal transaction abort during backendTom Lane
exit, instead of trying to take shortcuts. Introduce some additional shutdown callback routines to eliminate kluges like having ProcKill be responsible for shutting down the buffer manager. Ensure that the order of operations during shutdown is predictable and what you would expect given the module layering.
2005-07-31Add per-user and per-database connection limit options.Tom Lane
This patch also includes preliminary update of pg_dumpall for roles. Petr Jelinek, with review by Bruce Momjian and Tom Lane.
2005-07-29Clean up a number of autovacuum loose ends. Make the stats collectorTom Lane
track shared relations in a separate hashtable, so that operations done from different databases are counted correctly. Add proper support for anti-XID-wraparound vacuuming, even in databases that are never connected to and so have no stats entries. Miscellaneous other bug fixes. Alvaro Herrera, some additional fixes by Tom Lane.
2005-07-28Make use of new list primitives list_append_unique and list_concat_uniqueTom Lane
where applicable.
2005-07-25Add SET ROLE. This is a partial commit of Stephen Frost's recent patch;Tom Lane
I'm still working on the has_role function and information_schema changes.
2005-07-14Integrate autovacuum functionality into the backend. There's still aTom Lane
few loose ends to be dealt with, but it seems to work. Alvaro Herrera, based on the contrib code by Matthew O'Connor.
2005-07-04Arrange for the postmaster (and standalone backends, initdb, etc) toTom Lane
chdir into PGDATA and subsequently use relative paths instead of absolute paths to access all files under PGDATA. This seems to give a small performance improvement, and it should make the system more robust against naive DBAs doing things like moving a database directory that has a live postmaster in it. Per recent discussion.
2005-06-29More cleanup on roles patch. Allow admin option to be inherited throughTom Lane
role memberships; make superuser/createrole distinction do something useful; fix some locking and CommandCounterIncrement issues; prevent creation of loops in the membership graph.
2005-06-28Fix up problems in write_auth_file and parsing of the auth file.Tom Lane
In particular, make hba.c cope with zero-length tokens, which it never did properly before. Also, enforce rolcanlogin.
2005-06-28Bring syntax of role-related commands into SQL compliance. To avoidTom Lane
syntactic conflicts, both privilege and role GRANT/REVOKE commands have to use the same production for scanning the list of tokens that might eventually turn out to be privileges or role names. So, change the existing GRANT/REVOKE code to expect a list of strings not pre-reduced AclMode values. Fix a couple other minor issues while at it, such as InitializeAcl function name conflicting with a Windows system function.
2005-06-28Replace pg_shadow and pg_group by new role-capable catalogs pg_authidTom Lane
and pg_auth_members. There are still many loose ends to finish in this patch (no documentation, no regression tests, no pg_dump support for instance). But I'm going to commit it now anyway so that Alvaro can make some progress on shared dependencies. The catalog changes should be pretty much done.
2005-06-24This trivial patch removes an unused variable. From Alvaro Herrera.Neil Conway
2005-06-20Add lock file contents printout to "can't happen" case to helpTom Lane
investigate buildfarm failures.
2005-06-17Two-phase commit. Original patch by Heikki Linnakangas, with additionalTom Lane
hacking by Alvaro Herrera and Tom Lane.
2005-06-07Mention ipcrm and ipcclean in error message.Bruce Momjian
2005-06-07Ipcrm -> ipcclean in error message:Bruce Momjian
--------------------------------------------------------------------------- While playing around, I got the following error message: -- FATAL: pre-existing shared memory block (key 5432001, ID 90898435) is still in use HINT: If you're sure there are no old server processes still running, remove the shared memory block with the command "ipcrm", or just delete the file "/home/hlinnaka/pgsql/data/postmaster.pid". --- Thats normal because I used "kill -9 postmaster" to shut down. The hint advises me to use "ipcrm", but there's the "ipcclean" script in bin for just this purpose. The hint should probably advise to use ipcclean. The attached patch replaces all occurances of "ipcrm" with "ipcclean" in src/backend/utils/init/miscinit.c and all the translations in src/backend/po. While reviewing the patch, I noticed a likely typo in hr.po. While I don't speak Croatian, the translation seems to advise to use the "icpm(1)" command. I changed that to "ipcclean" too. Heikki Linnakangas
2005-06-06Remove the mostly-stubbed-out-anyway support routines for WAL UNDO.Tom Lane
That code is never going to be used in the foreseeable future, and where it's more than a stub it's making the redo routines harder to read.
2005-05-19Split the shared-memory array of PGPROC pointers out of the sinvalTom Lane
communication structure, and make it its own module with its own lock. This should reduce contention at least a little, and it definitely makes the code seem cleaner. Per my recent proposal.
2005-05-10Back out check for unreferenced files.Bruce Momjian
Heikki Linnakangas
2005-05-05Fix bogus hashtable setup. (This code has quite a few other problemsTom Lane
too, but that one is in my way at the moment.)
2005-05-05Make standalone backends ignore pg_database.datallowconn, so that thereTom Lane
is a way to recover from disabling connections to all databases at once.
2005-05-02Check the file system on postmaster startup and report any unreferencedBruce Momjian
files in the server log. Heikki Linnakangas