summaryrefslogtreecommitdiff
path: root/contrib
AgeCommit message (Collapse)Author
2013-01-13Improve handling of ereport(ERROR) and elog(ERROR).Tom Lane
In commit 71450d7fd6c7cf7b3e38ac56e363bff6a681973c, we added code to inform suitably-intelligent compilers that ereport() doesn't return if the elevel is ERROR or higher. This patch extends that to elog(), and also fixes a double-evaluation hazard that the previous commit created in ereport(), as well as reducing the emitted code size. The elog() improvement requires the compiler to support __VA_ARGS__, which should be available in just about anything nowadays since it's required by C99. But our minimum language baseline is still C89, so add a configure test for that. The previous commit assumed that ereport's elevel could be evaluated twice, which isn't terribly safe --- there are already counterexamples in xlog.c. On compilers that have __builtin_constant_p, we can use that to protect the second test, since there's no possible optimization gain if the compiler doesn't know the value of elevel. Otherwise, use a local variable inside the macros to prevent double evaluation. The local-variable solution is inferior because (a) it leads to useless code being emitted when elevel isn't constant, and (b) it increases the optimization level needed for the compiler to recognize that subsequent code is unreachable. But it seems better than not teaching non-gcc compilers about unreachability at all. Lastly, if the compiler has __builtin_unreachable(), we can use that instead of abort(), resulting in a noticeable code savings since no function call is actually emitted. However, it seems wise to do this only in non-assert builds. In an assert build, continue to use abort(), so that the behavior will be predictable and debuggable if the "impossible" happens. These changes involve making the ereport and elog macros emit do-while statement blocks not just expressions, which forces small changes in a few call sites. Andres Freund, Tom Lane, Heikki Linnakangas
2013-01-12Extend and improve use of EXTRA_REGRESS_OPTS.Andrew Dunstan
This is now used by ecpg tests, and not clobbered by pg_upgrade tests. This change won't affect anything that doesn't set this environment variable, but will enable the buildfarm to control exactly what port regression test installs will be running on, and thus to detect possible rogue postmasters more easily. Backpatch to release 9.2 where EXTRA_REGRESS_OPTS was first used.
2013-01-09Allow parallel copy/link in pg_upgradeBruce Momjian
This patch implements parallel copying/linking of files by tablespace using the --jobs option in pg_upgrade.
2013-01-07Add new "-q" logging option (quiet mode) while in initialize modeTatsuo Ishii
(-i), producing only one progress message per 5 seconds along with elapsed time and estimated remaining time. Also add elapsed time and estimated remaining time to the default logging(prints one message each 100000 rows). Patch contributed by Tomas Vondra, reviewed by Jeevan Chalke and Tatsuo Ishii.
2013-01-03Prevent creation of postmaster's TCP socket during pg_upgrade testing.Tom Lane
On non-Windows machines, we use the Unix socket for connections to test postmasters, so there is no need to create a TCP socket. Furthermore, doing so causes failures due to port conflicts if two builds are carried out concurrently on one machine. (If the builds are done in different chroots, which is standard practice at least in Red Hat distros, there is no risk of conflict on the Unix socket.) Suppressing the TCP socket by setting listen_addresses to empty has long been standard practice for pg_regress, and pg_upgrade knows about this too ... but pg_upgrade's test.sh didn't get the memo. Back-patch to 9.2, and also sync the 9.2 version of the script with HEAD as much as practical.
2013-01-02Adjust a few pg_upgrade functions to return void.Bruce Momjian
Adjust pg_upgrade page conversion functions (which are not used) to return void so transfer_all_new_dbs can return void.
2013-01-01Update copyrights for 2013Bruce Momjian
Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
2012-12-26Add pg_upgrade --jobs parameterBruce Momjian
Add pg_upgrade --jobs, which allows parallel dump/restore of databases, which improves performance.
2012-12-20Avoid using NAMEDATALEN in pg_upgradeBruce Momjian
Because the client encoding might not match the server encoding, pg_upgrade can't allocate NAMEDATALEN bytes for storage of database, relation, and namespace identifiers. Instead pg_strdup() the memory and free it. Also add C comment in initdb.c about safe NAMEDATALEN usage.
2012-12-20Add pg_upgrade comment about mismatch errorBruce Momjian
Add comment stating that constraint and index names must match.
2012-12-11Fix pg_upgrade for invalid indexesBruce Momjian
All versions of pg_upgrade upgraded invalid indexes caused by CREATE INDEX CONCURRENTLY failures and marked them as valid. The patch adds a check to all pg_upgrade versions and throws an error during upgrade or --check. Backpatch to 9.2, 9.1, 9.0. Patch slightly adjusted.
2012-12-11Add mode where contrib installcheck runs each module in a separately named ↵Andrew Dunstan
database. Normally each module is tested in a database named contrib_regression, which is dropped and recreated at the beginhning of each pg_regress run. This new mode, enabled by adding USE_MODULE_DB=1 to the make command line, runs most modules in a database with the module name embedded in it. This will make testing pg_upgrade on clusters with the contrib modules a lot easier. Second attempt at this, this time accomodating make versions older than 3.82. Still to be done: adapt to the MSVC build system. Backpatch to 9.0, which is the earliest version it is reasonably possible to test upgrading from.
2012-12-10Fix pg_upgrade -O/-o optionsBruce Momjian
Fix previous commit that added synchronous_commit=off, but broke -O/-o due to missing space in argument passing. Backpatch to 9.2.
2012-12-07Improve pg_upgrade's status displayBruce Momjian
Pg_upgrade displays file names during copy and database names during dump/restore. Andrew Dunstan identified three bugs: * long file names were being truncated to 60 _leading_ characters, which often do not change for long file names * file names were truncated to 60 characters in log files * carriage returns were being output to log files This commit fixes these --- it prints 60 _trailing_ characters to the status display, and full path names without carriage returns to log files. It also suppresses status output to the log file unless verbose mode is used.
2012-12-06Background worker processesAlvaro Herrera
Background workers are postmaster subprocesses that run arbitrary user-specified code. They can request shared memory access as well as backend database connections; or they can just use plain libpq frontend database connections. Modules listed in shared_preload_libraries can register background workers in their _PG_init() function; this is early enough that it's not necessary to provide an extra GUC option, because the necessary extra resources can be allocated early on. Modules can install more than one bgworker, if necessary. Care is taken that these extra processes do not interfere with other postmaster tasks: only one such process is started on each ServerLoop iteration. This means a large number of them could be waiting to be started up and postmaster is still able to quickly service external connection requests. Also, shutdown sequence should not be impacted by a worker process that's reasonably well behaved (i.e. promptly responds to termination signals.) The current implementation lets worker processes specify their start time, i.e. at what point in the server startup process they are to be started: right after postmaster start (in which case they mustn't ask for shared memory access), when consistent state has been reached (useful during recovery in a HOT standby server), or when recovery has terminated (i.e. when normal backends are allowed). In case of a bgworker crash, actions to take depend on registration data: if shared memory was requested, then all other connections are taken down (as well as other bgworkers), just like it were a regular backend crashing. The bgworker itself is restarted, too, within a configurable timeframe (which can be configured to be never). More features to add to this framework can be imagined without much effort, and have been discussed, but this seems good enough as a useful unit already. An elementary sample module is supplied. Author: Álvaro Herrera This patch is loosely based on prior patches submitted by KaiGai Kohei, and unsubmitted code by Simon Riggs. Reviewed by: KaiGai Kohei, Markus Wanner, Andres Freund, Heikki Linnakangas, Simon Riggs, Amit Kapila
2012-12-05Add pgstatginindex() function to get the size of the GIN pending list.Heikki Linnakangas
Fujii Masao, reviewed by Kyotaro Horiguchi.
2012-12-04In pg_upgrade testing script, turn off command echo at the end so statusBruce Momjian
report is clearer.
2012-12-03Restore set -x in pg_upgrade/test.sh, so the user can see what is beingBruce Momjian
executed.
2012-12-03Add initdb --sync-only option to sync the data directory to durableBruce Momjian
storage. Have pg_upgrade use it, and enable server options fsync=off and full_page_writes=off. Document that users turning fsync from off to on should run initdb --sync-only. [ Previous commit was incorrectly applied as a git merge. ]
2012-12-03Revert initdb --sync-only patch that had incorrect commit messages.Bruce Momjian
2012-12-03dummy commitBruce Momjian
2012-12-03dummy commitBruce Momjian
2012-12-03Revert "Add mode where contrib installcheck runs each module in a separately ↵Andrew Dunstan
named database." This reverts commit e2b3c21b05c78c3a726b189242e41d4aa4422bf1.
2012-12-02Add mode where contrib installcheck runs each module in a separately named ↵Andrew Dunstan
database. Normally each module is tested in aq database named contrib_regression, which is dropped and recreated at the beginhning of each pg_regress run. This mode, enabled by adding USE_MODULE_DB=1 to the make command line, runs most modules in a database with the module name embedded in it. This will make testing pg_upgrade on clusters with the contrib modules a lot easier. Still to be done: adapt to the MSVC build system. Backpatch to 9.0, which is the earliest version it is reasonably possible to test upgrading from.
2012-12-01In pg_upgrade, remove 'set -x' from test script.Bruce Momjian
2012-12-01Revert:Bruce Momjian
In pg_upgrade, remove pg_restore's --single-transaction option, as it throws errors in certain cases.
2012-12-01Remove pg_restore's --single-transaction option, as it throws errors inBruce Momjian
certain cases.
2012-11-30In pg_upgrade, improve status wording now that we have per-databaseBruce Momjian
status output for dump/restore.
2012-11-30Take buffer lock while inspecting btree index pages in contrib/pageinspect.Tom Lane
It's not safe to examine a shared buffer without any lock.
2012-11-30In pg_upgrade, dump each database separately and useBruce Momjian
--single-transaction to restore each database schema. This yields performance improvements for databases with many tables. Also, remove split_old_dump() as it is no longer needed.
2012-11-30Move long_options structures to the top of main() functions, forBruce Momjian
consistency. Per suggestion from Tom.
2012-11-30Clean environment for pg_upgrade test.Andrew Dunstan
This removes exisiting PG settings from the environment for pg_upgrade tests, just like pg_regress does.
2012-11-28Fix assorted bugs in CREATE/DROP INDEX CONCURRENTLY.Tom Lane
Commit 8cb53654dbdb4c386369eb988062d0bbb6de725e, which introduced DROP INDEX CONCURRENTLY, managed to break CREATE INDEX CONCURRENTLY via a poor choice of catalog state representation. The pg_index state for an index that's reached the final pre-drop stage was the same as the state for an index just created by CREATE INDEX CONCURRENTLY. This meant that the (necessary) change to make RelationGetIndexList ignore about-to-die indexes also made it ignore freshly-created indexes; which is catastrophic because the latter do need to be considered in HOT-safety decisions. Failure to do so leads to incorrect index entries and subsequently wrong results from queries depending on the concurrently-created index. To fix, add an additional boolean column "indislive" to pg_index, so that the freshly-created and about-to-die states can be distinguished. (This change obviously is only possible in HEAD. This patch will need to be back-patched, but in 9.2 we'll use a kluge consisting of overloading the formerly-impossible state of indisvalid = true and indisready = false.) In addition, change CREATE/DROP INDEX CONCURRENTLY so that the pg_index flag changes they make without exclusive lock on the index are made via heap_inplace_update() rather than a normal transactional update. The latter is not very safe because moving the pg_index tuple could result in concurrent SnapshotNow scans finding it twice or not at all, thus possibly resulting in index corruption. This is a pre-existing bug in CREATE INDEX CONCURRENTLY, which was copied into the DROP code. In addition, fix various places in the code that ought to check to make sure that the indexes they are manipulating are valid and/or ready as appropriate. These represent bugs that have existed since 8.2, since a failed CREATE INDEX CONCURRENTLY could leave a corrupt or invalid index behind, and we ought not try to do anything that might fail with such an index. Also fix RelationReloadIndexInfo to ensure it copies all the pg_index columns that are allowed to change after initial creation. Previously we could have been left with stale values of some fields in an index relcache entry. It's not clear whether this actually had any user-visible consequences, but it's at least a bug waiting to happen. In addition, do some code and docs review for DROP INDEX CONCURRENTLY; some cosmetic code cleanup but mostly addition and revision of comments. This will need to be back-patched, but in a noticeably different form, so I'm committing it to HEAD before working on the back-patch. Problem reported by Amit Kapila, diagnosis by Pavan Deolassee, fix by Tom Lane and Andres Freund.
2012-11-24In pg_upgrade, simplify function copy_file() by using pg_malloc() andBruce Momjian
centralizing error/shutdown code.
2012-11-24In pg_upgrade, fix a few place that used maloc/free rather thanBruce Momjian
pg_malloc/pg_free.
2012-11-19In pg_upgrade, report errno string if file existence check returns anBruce Momjian
error and errno != ENOENT.
2012-11-18Limit values of archive_timeout, post_auth_delay, auth_delay.milliseconds.Tom Lane
The previous definitions of these GUC variables allowed them to range up to INT_MAX, but in point of fact the underlying code would suffer overflows or other errors with large values. Reduce the maximum values to something that won't misbehave. There's no apparent value in working harder than this, since very large delays aren't sensible for any of these. (Note: the risk with archive_timeout is that if we're late checking the state, the timestamp difference it's being compared to might overflow. So we need some amount of slop; the choice of INT_MAX/2 is arbitrary.) Per followup investigation of bug #7670. Although this isn't a very significant fix, might as well back-patch.
2012-11-14In pg_upgrade, add third meaningless parameter to open().Bruce Momjian
2012-11-14In pg_upgrade, copy fsm, vm, and extent files by checking for fileBruce Momjian
existence via open(), rather than collecting a directory listing and looking up matching relfilenode files with sequential scans of the array. This speeds up pg_upgrade by 2x for a large number of tables, e.g. 16k. Per observation by Ants Aasma.
2012-11-13Mark pg_upgrade's free_db_and_rel_infos() as a static function.Bruce Momjian
2012-11-12Oops, have to rename local variables called 'errcontext' in contrib, too.Heikki Linnakangas
As pointed out by Alvaro.
2012-11-06In pg_upgrade, set synchronous_commit=off for the new cluster, toBruce Momjian
improve performance when restoring the schema from the old cluster. Backpatch to 9.2.
2012-10-23Add context info to OAT_POST_CREATE security hookAlvaro Herrera
... and have sepgsql use it to determine whether to check permissions during certain operations. Indexes that are being created as a result of REINDEX, for instance, do not need to have their permissions checked; they were already checked when the index was created. Author: KaiGai Kohei, slightly revised by me
2012-10-20Prevent overflow in pgbench's percent-done display.Tom Lane
Per Thom Brown.
2012-10-18Use a more portable platform test.Andrew Dunstan
2012-10-12In our source code, make a copy of getopt's 'optarg' string arguments,Bruce Momjian
rather than just storing a pointer.
2012-10-12Fix unportable format string.Tom Lane
Per compiler warning.
2012-10-11Refactor flex and bison make rulesPeter Eisentraut
Numerous flex and bison make rules have appeared in the source tree over time, and they are all virtually identical, so we can replace them by pattern rules with some variables for customization. Users of pgxs will also be able to benefit from this.
2012-10-10Remove configure-option-dependent test cases from dblink tests.Tom Lane
The HINTs generated for these error cases vary across builds. We could try to work around that, but the test cases aren't really useful enough to justify taking any trouble. Per buildfarm.
2012-10-10Create an improved FDW option validator function for contrib/dblink.Tom Lane
dblink now has its own validator function dblink_fdw_validator(), which is better than the core function postgresql_fdw_validator() because it gets the list of legal options from libpq instead of having a hard-wired list. Make the dblink extension module provide a standard foreign data wrapper dblink_fdw that encapsulates use of this validator, and recommend use of that wrapper instead of making up wrappers on the fly. Unfortunately, because ad-hoc wrappers *were* recommended practice previously, it's not clear when we can get rid of postgresql_fdw_validator without causing upgrade problems. But this is a step in the right direction. Shigeru Hanada, reviewed by KaiGai Kohei