aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* Remove duplicate initialization in XLogReadRecord.Robert Haas2013-04-09
| | | | Per a note from Dickson S. Guedes.
* Create a distinction between a populated matview and a scannable one.Kevin Grittner2013-04-09
| | | | | | | | | | | | | | | | The intent was that being populated would, long term, be just one of the conditions which could affect whether a matview was scannable; being populated should be necessary but not always sufficient to scan the relation. Since only CREATE and REFRESH currently determine the scannability, names and comments accidentally conflated these concepts, leading to confusion. Also add missing locking for the SQL function which allows a test for scannability, and fix a modularity violatiion. Per complaints from Tom Lane, although its not clear that these will satisfy his concerns. Hopefully this will at least better frame the discussion.
* Adjust ExplainOneQuery_hook_type to take a DestReceiver argument.Robert Haas2013-04-09
| | | | | | | | The materialized views patch adjusted ExplainOneQuery to take an additional DestReceiver argument, but failed to add a matching argument to the definition of ExplainOneQuery_hook. This is a problem for users of the hook that want to call ExplainOnePlan. Fix by adding the missing argument.
* Support indexing of regular-expression searches in contrib/pg_trgm.Tom Lane2013-04-09
| | | | | | | | | | | | | | | | This works by extracting trigrams from the given regular expression, in generally the same spirit as the previously-existing support for LIKE searches, though of course the details are far more complicated. Currently, only GIN indexes are supported. We might be able to make it work with GiST indexes later. The implementation includes adding API functions to backend/regex/ to provide a view of the search NFA created from a regular expression. These functions are meant to be generic enough to be supportable in a standalone version of the regex library, should that ever happen. Alexander Korotkov, reviewed by Heikki Linnakangas and Tom Lane
* Minor rewording of README commentsSimon Riggs2013-04-08
|
* Fix calculation of how many segments to retain for wal_keep_segments.Heikki Linnakangas2013-04-08
| | | | | | | KeepLogSeg function was broken when we switched to use a 64-bit int for the segment number. Per report from Jeff Janes.
* Skip extraneous locking in XLogCheckBuffer().Simon Riggs2013-04-08
| | | | | | | Heikki reported comment was wrong, so fixed code to match the comment: we only need to take additional locking precautions when we have a shared lock on the buffer.
* Avoid tricky race condition recording XLOG_HINTSimon Riggs2013-04-08
| | | | | | | | | | | | | | | | | | We copy the buffer before inserting an XLOG_HINT to avoid WAL CRC errors caused by concurrent hint writes to buffer while share locked. To make this work we refactor RestoreBackupBlock() to allow an XLOG_HINT to avoid the normal path for backup blocks, which assumes the underlying buffer is exclusive locked. Resulting code completely changes layout of XLOG_HINT WAL records, but this isn't even beta code, so this is a low impact change. In passing, avoid taking WALInsertLock for full page writes on checksummed hints, remove related cruft from XLogInsert() and improve xlog_desc record for XLOG_HINT. Andres Freund Bug report by Fujii Masao, testing by Jeff Janes and Jaime Casanova, review by Jeff Davis and Simon Riggs. Applied with changes from review and some comment editing.
* README comments on checksums on page holes.Simon Riggs2013-04-08
|
* Tune BufferGetLSNAtomic() when checksums !enabledSimon Riggs2013-04-07
| | | | From performance analysis by Heikki Linnakangas
* Fix checksums for CLUSTER, VACUUM FULL etc.Simon Riggs2013-04-07
| | | | | | | | | In CLUSTER, VACUUM FULL and ALTER TABLE SET TABLESPACE I erroneously set checksum before log_newpage, which sets the LSN and invalidates the checksum. So set checksum immediately *after* log_newpage. Bug report Fujii Masao, Fix and patch by Jeff Davis
* In isolationtester, retry after EINTR return from select(2).Tom Lane2013-04-06
| | | | | Per report from Jaime Casanova. Very curious that no one else has seen this failure ... but the code is clearly wrong as-is.
* sepgsql: Enforce db_schema:search permission.Robert Haas2013-04-05
| | | | KaiGai Kohei, with comment and doc wordsmithing by me
* Fix line count in slashUsage().Tom Lane2013-04-04
| | | | | | | | Counting newlines shows that quite a few recent patches have neglected to update the output-lines count given to PageOutput(). Fortunately it's not terribly critical that this be exact, since we long since exceeded the height of most people's terminal windows. Still, maybe we ought to think of a way to not have to maintain this manually anymore.
* Add \watch [SEC] command to psql.Tom Lane2013-04-04
| | | | | | This allows convenient re-execution of commands. Will Leinweber, reviewed by Peter Eisentraut, Daniel Farina, and Tom Lane
* Fix off by one error in JSON extract path code.Andrew Dunstan2013-04-04
| | | | Bug report by David Wheeler, diagnosis assistance from Tom Lane.
* psql: fix startup crash caused by PSQLRC containing a tildeBruce Momjian2013-04-04
| | | | | | | 'strdup' the PSQLRC environment variable value before calling a routine that might free() it. Backpatch to 9.2, where the bug first appeared.
* Fix crash on compiling a regular expression with more than 32k colors.Heikki Linnakangas2013-04-04
| | | | | | Throw an error instead. Backpatch to all supported branches.
* Calculate # of semaphores correctly with --disable-spinlocks.Heikki Linnakangas2013-04-04
| | | | | | | | | | The old formula didn't take into account that each WAL sender process needs a spinlock. We had also already exceeded the fixed number of spinlocks reserved for misc purposes (10). Bump that to 30. Backpatch to 9.0, where WAL senders were introduced. If I counted correctly, 9.0 had exactly 10 predefined spinlocks, and 9.1 exceeded that, but bump the limit in 9.0 too because 10 is uncomfortably close to the edge.
* Avoid updating our PgBackendStatus entry when track_activities is off.Tom Lane2013-04-03
| | | | | | | | The point of turning off track_activities is to avoid this reporting overhead, but a thinko in commit 4f42b546fd87a80be30c53a0f2c897acb826ad52 caused pgstat_report_activity() to perform half of its updates anyway. Fix that, and also make sure that we clear all the now-disabled fields when transitioning to the non-reporting state.
* Minor robustness improvements for isolationtester.Tom Lane2013-04-02
| | | | | | | | | | | | | Notice and complain about PQcancel() failures. Also, don't dump core if an error PGresult doesn't contain severity and message subfields, as it might not if it was generated by libpq itself. (We have a longstanding TODO item to improve that, but in the meantime isolationtester had better cope.) I tripped across the latter item while investigating a trouble report on buildfarm member spoonbill. As for the former, there's no evidence that PQcancel failure is actually involved in spoonbill's problem, but it still seems like a bad idea to ignore an error return code.
* Fix insecure parsing of server command-line switches.Tom Lane2013-04-01
| | | | | | | | | | | | | | | | | | | | | | | | An oversight in commit e710b65c1c56ca7b91f662c63d37ff2e72862a94 allowed database names beginning with "-" to be treated as though they were secure command-line switches; and this switch processing occurs before client authentication, so that even an unprivileged remote attacker could exploit the bug, needing only connectivity to the postmaster's port. Assorted exploits for this are possible, some requiring a valid database login, some not. The worst known problem is that the "-r" switch can be invoked to redirect the process's stderr output, so that subsequent error messages will be appended to any file the server can write. This can for example be used to corrupt the server's configuration files, so that it will fail when next restarted. Complete destruction of database tables is also possible. Fix by keeping the database name extracted from a startup packet fully separate from command-line switches, as had already been done with the user name field. The Postgres project thanks Mitsumasa Kondo for discovering this bug, Kyotaro Horiguchi for drafting the fix, and Noah Misch for recognizing the full extent of the danger. Security: CVE-2013-1899
* Make REPLICATION privilege checks test current user not authenticated user.Tom Lane2013-04-01
| | | | | | | | | | | The pg_start_backup() and pg_stop_backup() functions checked the privileges of the initially-authenticated user rather than the current user, which is wrong. For example, a user-defined index function could successfully call these functions when executed by ANALYZE within autovacuum. This could allow an attacker with valid but low-privilege database access to interfere with creation of routine backups. Reported and fixed by Noah Misch. Security: CVE-2013-1901
* Revert "ecpg: Don't link compatlib with libpq"Peter Eisentraut2013-03-31
| | | | | | | | This reverts commit 3780fc679cc428c1f211e1728c4281ca15e9746b. HP-UX didn't like it. There would probably be a way to fix that, but since the net effect of all of this is zero because ecpg ends up using libpq anyway, it's not worth bothering further.
* Ignore extra subquery outputs in set_subquery_size_estimates().Tom Lane2013-03-31
| | | | | | | | | | | | In commit 0f61d4dd1b4f95832dcd81c9688dac56fd6b5687, I added code to copy up column width estimates for each column of a subquery. That code supposed that the subquery couldn't have any output columns that didn't correspond to known columns of the current query level --- which is true when a query is parsed from scratch, but the assumption fails when planning a view that depends on another view that's been redefined (adding output columns) since the upper view was made. This results in an assertion failure or even a crash, as per bug #8025 from lindebg. Remove the Assert and instead skip the column if its resno is out of the expected range.
* Add pkg-config files for libpq and ecpg librariesPeter Eisentraut2013-03-31
| | | | | | | | This will hopefully be easier to use than pg_config for users who are already used to the pkg-config interface. It also works better for multi-arch installations. reviewed by Tom Lane
* ecpg: Don't link compatlib with libpqPeter Eisentraut2013-03-31
| | | | | | | | It doesn't actually use libpq. But we need to keep libpq in the CPPFLAGS for building, because compatlib uses ecpglib.h which uses libpq-fe.h, but we don't need to refer to libpq for linking. reviewed by Tom Lane
* Improve code documentation about "magnetic disk" storage manager.Tom Lane2013-03-30
| | | | | | | The modern incarnation of md.c is by no means specific to magnetic disk technology, but every so often we hear from someone who's misled by the label. Try to clarify that it will work for anything that supports standard filesystem operations. Per suggestion from Andrew Dunstan.
* ecpg: Parallel make fixPeter Eisentraut2013-03-29
| | | | | | | In some parallel make situations, the install-headers target could be called before the installation directories are created by installdirs, causing the installation to fail. Fix that by making install-headers depend on installdirs.
* Add new JSON processing functions and parser API.Andrew Dunstan2013-03-29
| | | | | | | | | | | | | | | | | The JSON parser is converted into a recursive descent parser, and exposed for use by other modules such as extensions. The API provides hooks for all the significant parser event such as the beginning and end of objects and arrays, and providing functions to handle these hooks allows for fairly simple construction of a wide variety of JSON processing functions. A set of new basic processing functions and operators is also added, which use this API, including operations to extract array elements, object fields, get the length of arrays and the set of keys of a field, deconstruct an object into a set of key/value pairs, and create records from JSON objects and arrays of objects. Catalog version bumped. Andrew Dunstan, with some documentation assistance from Merlin Moncure.
* Must check indisready not just indisvalid when dumping from 9.2 server.Tom Lane2013-03-28
| | | | | | | | | | 9.2 uses a kluge representation of "indislive"; we have to account for that when examining pg_index. Simplest solution is to check indisready for 9.0 and 9.1 as well; that's harmless though unnecessary, so it's not worth making a version distinction for. Fixes oversight in commit 683abc73dff549e94555d4020dae8d02f32ed78b, as noted by Andres Freund.
* Update time zone data files to tzdata release 2013b.Tom Lane2013-03-28
| | | | | DST law changes in Chile, Haiti, Morocco, Paraguay, some Russian areas. Historical corrections for numerous places.
* Avoid "variable might be clobbered by longjmp" warning.Tom Lane2013-03-28
| | | | | | | On older-model gcc, the original coding of UTILITY_BEGIN_QUERY() can draw this error because of multiple assignments to _needCleanup. Rather than mark that variable volatile, we can suppress the warning by arranging to have just one unconditional assignment before PG_TRY.
* Add sql_drop event for event triggersAlvaro Herrera2013-03-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This event takes place just before ddl_command_end, and is fired if and only if at least one object has been dropped by the command. (For instance, DROP TABLE IF EXISTS of a table that does not in fact exist will not lead to such a trigger firing). Commands that drop multiple objects (such as DROP SCHEMA or DROP OWNED BY) will cause a single event to fire. Some firings might be surprising, such as ALTER TABLE DROP COLUMN. The trigger is fired after the drop has taken place, because that has been deemed the safest design, to avoid exposing possibly-inconsistent internal state (system catalogs as well as current transaction) to the user function code. This means that careful tracking of object identification is required during the object removal phase. Like other currently existing events, there is support for tag filtering. To support the new event, add a new pg_event_trigger_dropped_objects() set-returning function, which returns a set of rows comprising the objects affected by the command. This is to be used within the user function code, and is mostly modelled after the recently introduced pg_identify_object() function. Catalog version bumped due to the new function. Dimitri Fontaine and Álvaro Herrera Review by Robert Haas, Tom Lane
* Revoke bc5334d8679c428a709d150666b288171795bd76Simon Riggs2013-03-28
|
* Revoke 7a5a59d378e052618d6feae64d1d2b4f2ad6f9bcSimon Riggs2013-03-28
|
* Reset OpenSSL randomness state in each postmaster child process.Tom Lane2013-03-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if the postmaster initialized OpenSSL's PRNG (which it will do when ssl=on in postgresql.conf), the same pseudo-random state would be inherited by each forked child process. The problem is masked to a considerable extent if the incoming connection uses SSL encryption, but when it does not, identical pseudo-random state is made available to functions like contrib/pgcrypto. The process's PID does get mixed into any requested random output, but on most systems that still only results in 32K or so distinct random sequences available across all Postgres sessions. This might allow an attacker who has database access to guess the results of "secure" operations happening in another session. To fix, forcibly reset the PRNG after fork(). Each child process that has need for random numbers from OpenSSL's generator will thereby be forced to go through OpenSSL's normal initialization sequence, which should provide much greater variability of the sequences. There are other ways we might do this that would be slightly cheaper, but this approach seems the most future-proof against SSL-related code changes. This has been assigned CVE-2013-1900, but since the issue and the patch have already been publicized on pgsql-hackers, there's no point in trying to hide this commit. Back-patch to all supported branches. Marko Kreen
* Fix buffer pin leak in heap update redo routine.Heikki Linnakangas2013-03-27
| | | | | | | | | | | | | | In a heap update, if the old and new tuple were on different pages, and the new page no longer existed (because it was subsequently truncated away by vacuum), heap_xlog_update forgot to release the pin on the old buffer. This bug was introduced by the "Fix multiple problems in WAL replay" patch, commit 3bbf668de9f1bc172371681e80a4e769b6d014c8 (on master branch). With full_page_writes=off, this triggered an "incorrect local pin count" error later in replay, if the old page was vacuumed. This fixes bug #7969, reported by Yunong Xiao. Backpatch to 9.0, like the commit that introduced this bug.
* Set recovery_config_directory for EXEC_BACKEND.Simon Riggs2013-03-27
| | | | | Remove comment questioning whether this is necessary for DataDir. From buildfarm failures on Windows.
* Move some pg_dump function around.Heikki Linnakangas2013-03-27
| | | | | | | | | | | | | | | | | Move functions used only by pg_dump and pg_restore from dumputils.c to a new file, pg_backup_utils.c. dumputils.c is linked into psql and some programs in bin/scripts, so it seems good to keep it slim. The parallel functionality is moved to parallel.c, as is exit_horribly, because the interesting code in exit_horribly is parallel-related. This refactoring gets rid of the on_exit_msg_func function pointer. It was problematic, because a modern gcc version with -Wmissing-format-attribute complained if it wasn't marked with PF_PRINTF_ATTRIBUTE, but the ancient gcc version that Tom Lane's old HP-UX box has didn't accept that attribute on a function pointer, and gave an error. We still use a similar function pointer trick for getLocalPQBuffer() function, to use a thread-local version of that in parallel mode on Windows, but that dodges the problem because it doesn't take printf-like arguments.
* Allow external recovery_config_directorySimon Riggs2013-03-27
| | | | | If required, recovery.conf can now be located outside of the data directory. Server needs read/write permissions on this directory.
* Fix grammatical errors in some new message strings.Tom Lane2013-03-26
| | | | Daniele Varrazzo
* Ignore invalid indexes in pg_dump.Tom Lane2013-03-26
| | | | | | | | | | | | | | Dumping invalid indexes can cause problems at restore time, for example if the reason the index creation failed was because it tried to enforce a uniqueness condition not satisfied by the table's data. Also, if the index creation is in fact still in progress, it seems reasonable to consider it to be an uncommitted DDL change, which pg_dump wouldn't be expected to dump anyway. Back-patch to all active versions, and teach them to ignore invalid indexes in servers back to 8.2, where the concept was introduced. Michael Paquier
* Fix pg_dump against 9.1/9.2 servers.Heikki Linnakangas2013-03-26
| | | | | | | The parallel pg_dump patch forgot to add relpages column to 9.1/9.2 version of the getTables() query. Reported by Bernd Helmle.
* Get rid of obsolete parse_version helper function.Heikki Linnakangas2013-03-26
| | | | | | | For getting the server's version in numeric form, use PQserverVersion(). It does the exact same parsing as dumputils.c's parse_version(), and has been around in libpq for a long time. For the client's version, just use the PG_VERSION_NUM constant.
* Fix a small logic bug in adjusted parallel restore code.Andrew Dunstan2013-03-25
|
* In base backup, only include our own tablespace version directory.Heikki Linnakangas2013-03-25
| | | | | | | | If you have clusters of different versions pointing to the same tablespace location, we would incorrectly include all the data belonging to the other versions, too. Fixes bug #7986, reported by Sergey Burladyan.
* Make pg_basebackup work with pre-9.3 servers, and add server version check.Heikki Linnakangas2013-03-25
| | | | | | | | | | | | | | | A new 'starttli' field was added to the response of BASE_BACKUP command. Make pg_basebackup tolerate the case that it's missing, so that it still works with older servers. Add an explicit check for the server version, so that you get a nicer error message if you try to use it with a pre-9.1 server. The streaming protocol message format changed in 9.3, so -X stream still won't work with pre-9.3 servers. I added a version check to ReceiveXLogStream() earlier, but write that slightly differently, so that in 9.4, it will still work with a 9.3 server. (In 9.4, the error message needs to be adjusted to "9.3 or above", though). Also, if the version check fails, don't retry.
* Add PF_PRINTF_ATTRIBUTE to on_exit_msg_fmt.Heikki Linnakangas2013-03-25
| | | | Per warning from -Wmissing-format-attribute.
* Add missing #include.Heikki Linnakangas2013-03-25
| | | | time(2) requires time.h.