aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* pg_event_trigger_dropped_objects: add behavior flagsAlvaro Herrera2014-12-19
| | | | | | | | | | | | | | | | | Add "normal" and "original" flags as output columns to the pg_event_trigger_dropped_objects() function. With this it's possible to distinguish which objects, among those listed, need to be explicitely referenced when trying to replicate a deletion. This is necessary so that the list of objects can be pruned to the minimum necessary to replicate the DROP command in a remote server that might have slightly different schema (for instance, TOAST tables and constraints with different names and such.) Catalog version bumped due to change of function definition. Reviewed by: Abhijit Menon-Sen, Stephen Frost, Heikki Linnakangas, Robert Haas.
* Fix timestamp in end-of-recovery WAL records.Heikki Linnakangas2014-12-19
| | | | | | | We used time(null) to set a TimestampTz field, which gave bogus results. Noticed while looking at pg_xlogdump output. Backpatch to 9.3 and above, where the fast promotion was introduced.
* Prevent potentially hazardous compiler/cpu reordering during lwlock release.Andres Freund2014-12-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | In LWLockRelease() (and in 9.4+ LWLockUpdateVar()) we release enqueued waiters using PGSemaphoreUnlock(). As there are other sources of such unlocks backends only wake up if MyProc->lwWaiting is set to false; which is only done in the aforementioned functions. Before this commit there were dangers because the store to lwWaitLink could become visible before the store to lwWaitLink. This could both happen due to compiler reordering (on most compilers) and on some platforms due to the CPU reordering stores. The possible consequence of this is that a backend stops waiting before lwWaitLink is set to NULL. If that backend then tries to acquire another lock and has to wait there the list could become corrupted once the lwWaitLink store is finally performed. Add a write memory barrier to prevent that issue. Unfortunately the barrier support has been only added in 9.2. Given that the issue has not knowingly been observed in praxis it seems sufficient to prohibit compiler reordering using volatile for 9.0 and 9.1. Actual problems due to compiler reordering are more likely anyway. Discussion: 20140210134625.GA15246@awork2.anarazel.de
* Define Assert() et al to ((void)0) to avoid pedantic warnings.Andres Freund2014-12-19
| | | | | gcc's -Wempty-body warns about the current usage when compiling postgres without --enable-cassert.
* Use %u to print out BlockNumber variablesAlvaro Herrera2014-12-18
| | | | Per Tom Lane
* Have VACUUM log number of skipped pages due to pinsAlvaro Herrera2014-12-18
| | | | | | Author: Jim Nasby, some kibitzing by Heikki Linnankangas. Discussion leading to current behavior and precise wording fueled by thoughts from Robert Haas and Andres Freund.
* Improve hash_create's API for selecting simple-binary-key hash functions.Tom Lane2014-12-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if you wanted anything besides C-string hash keys, you had to specify a custom hashing function to hash_create(). Nearly all such callers were specifying tag_hash or oid_hash; which is tedious, and rather error-prone, since a caller could easily miss the opportunity to optimize by using hash_uint32 when appropriate. Replace this with a design whereby callers using simple binary-data keys just specify HASH_BLOBS and don't need to mess with specific support functions. hash_create() itself will take care of optimizing when the key size is four bytes. This nets out saving a few hundred bytes of code space, and offers a measurable performance improvement in tidbitmap.c (which was not exploiting the opportunity to use hash_uint32 for its 4-byte keys). There might be some wins elsewhere too, I didn't analyze closely. In future we could look into offering a similar optimized hashing function for 8-byte keys. Under this design that could be done in a centralized and machine-independent fashion, whereas getting it right for keys of platform-dependent sizes would've been notationally painful before. For the moment, the old way still works fine, so as not to break source code compatibility for loadable modules. Eventually we might want to remove tag_hash and friends from the exported API altogether, since there's no real need for them to be explicitly referenced from outside dynahash.c. Teodor Sigaev and Tom Lane
* Change how first WAL segment on new timeline after promotion is created.Heikki Linnakangas2014-12-18
| | | | | | | | | | | | | | Two changes: 1. When copying a WAL segment from old timeline to create the first segment on the new timeline, only copy up to the point where the timeline switch happens, and zero-fill the rest. This avoids corner cases where we might think that the copied WAL from the previous timeline belong to the new timeline. 2. If the timeline switch happens at a segment boundary, don't copy the whole old segment to the new timeline. It's pointless, because it's 100% identical to the old segment.
* Add memory barriers for PgBackendStatus.st_changecount protocol.Fujii Masao2014-12-18
| | | | | | | | | | | | | | | | | | st_changecount protocol needs the memory barriers to ensure that the apparent order of execution is as it desires. Otherwise, for example, the CPU might rearrange the code so that st_changecount is incremented twice before the modification on a machine with weak memory ordering. This surprising result can lead to bugs. This commit introduces the macros to load and store st_changecount with the memory barriers. These are called before and after PgBackendStatus entries are modified or copied into private memory, in order to prevent CPU from reordering PgBackendStatus access. Per discussion on pgsql-hackers, we decided not to back-patch this to 9.4 or before until we get an actual bug report about this. Patch by me. Review by Robert Haas.
* Ensure variables live across calls in generate_series(numeric, numeric).Fujii Masao2014-12-18
| | | | | | | | | | | In generate_series_step_numeric(), the variables "start_num" and "stop_num" may be potentially freed until the next call. So they should be put in the location which can survive across calls. But previously they were not, and which could cause incorrect behavior of generate_series(numeric, numeric). This commit fixes this problem by copying them on multi_call_memory_ctx. Andrew Gierth
* Update .gitignore for config.cache.Fujii Masao2014-12-18
| | | | | | Also add a comment about why regreesion.* aren't listed in .gitignore. Jim Nasby
* Adjust valgrind suppression to the changes in 2c03216d8311.Andres Freund2014-12-18
| | | | CRC computation is now done in XLogRecordAssemble.
* Recognize Makefile line continuations in fetchRegressOpts().Noah Misch2014-12-18
| | | | | | Back-patch to 9.0 (all supported versions). This is mere future-proofing in the context of the master branch, but commit f6dc6dd5ba54d52c0733aaafc50da2fbaeabb8b0 requires it of older branches.
* Remove odd blank line in comment.Fujii Masao2014-12-18
| | | | Etsuro Fujita
* Fix (re-)starting from a basebackup taken off a standby after a failure.Andres Freund2014-12-18
| | | | | | | | | | | | | | | | | | | | | | | | | | When starting up from a basebackup taken off a standby extra logic has to be applied to compute the point where the data directory is consistent. Normal base backups use a WAL record for that purpose, but that isn't possible on a standby. That logic had a error check ensuring that the cluster's control file indicates being in recovery. Unfortunately that check was too strict, disregarding the fact that the control file could also indicate that the cluster was shut down while in recovery. That's possible when the a cluster starting from a basebackup is shut down before the backup label has been removed. When everything goes well that's a short window, but when either restore_command or primary_conninfo isn't configured correctly the window can get much wider. That's because inbetween reading and unlinking the label we restore the last checkpoint from WAL which can need additional WAL. To fix simply also allow starting when the control file indicates "shutdown in recovery". There's nicer fixes imaginable, but they'd be more invasive. Backpatch to 9.2 where support for taking basebackups from standbys was added.
* Fix previous commit for TAP test suites in VPATH builds.Noah Misch2014-12-18
| | | | | Per buildfarm member crake. Back-patch to 9.4, where the TAP suites were introduced.
* Lock down regression testing temporary clusters on Windows.Noah Misch2014-12-17
| | | | | | | | | | | | Use SSPI authentication to allow connections exclusively from the OS user that launched the test suite. This closes on Windows the vulnerability that commit be76a6d39e2832d4b88c0e1cc381aa44a7f86881 closed on other platforms. Users of "make installcheck" or custom test harnesses can run "pg_regress --config-auth=DATADIR" to activate the same authentication configuration that "make check" would use. Back-patch to 9.0 (all supported versions). Security: CVE-2014-0067
* Allow CHECK constraints to be placed on foreign tables.Tom Lane2014-12-17
| | | | | | | | | | | | | | | As with NOT NULL constraints, we consider that such constraints are merely reports of constraints that are being enforced by the remote server (or other underlying storage mechanism). Their only real use is to allow planner optimizations, for example in constraint-exclusion checks. Thus, the code changes here amount to little more than removal of the error that was formerly thrown for applying CHECK to a foreign table. (In passing, do a bit of cleanup of the ALTER FOREIGN TABLE reference page, which had accumulated some weird decisions about ordering etc.) Shigeru Hanada and Etsuro Fujita, reviewed by Kyotaro Horiguchi and Ashutosh Bapat.
* Clarify the regexp used to detect source files in MSVC builds.Heikki Linnakangas2014-12-17
| | | | | | | | The old pattern would match files with strange extensions like *.ry or *.lpp. Refactor it to only include files with known extensions, and to make it more readable. Per Andrew Dunstan's suggestion.
* Fix another poorly worded error message.Tom Lane2014-12-17
| | | | Spotted by Álvaro Herrera.
* Fix poorly worded error message.Tom Lane2014-12-17
| | | | Adam Brightwell, per report from Martín Marqués.
* Add missing documentation for some vcregress modesMagnus Hagander2014-12-17
| | | | Michael Paquier
* Fix off-by-one loop count in MapArrayTypeName, and get rid of static array.Tom Lane2014-12-16
| | | | | | | | | | | | | | | | | | | | | MapArrayTypeName would copy up to NAMEDATALEN-1 bytes of the base type name, which of course is wrong: after prepending '_' there is only room for NAMEDATALEN-2 bytes. Aside from being the wrong result, this case would lead to overrunning the statically allocated work buffer. This would be a security bug if the function were ever used outside bootstrap mode, but it isn't, at least not in any currently supported branches. Aside from fixing the off-by-one loop logic, this patch gets rid of the static work buffer by having MapArrayTypeName pstrdup its result; the sole caller was already doing that, so this just requires moving the pstrdup call. This saves a few bytes but mainly it makes the API a lot cleaner. Back-patch on the off chance that there is some third-party code using MapArrayTypeName with less-secure input. Pushing pstrdup into the function should not cause any serious problems for such hypothetical code; at worst there might be a short term memory leak. Per Coverity scanning.
* Fix some jsonb issues found by Coverity in recent commits.Andrew Dunstan2014-12-16
| | | | | | | | | | | | Mostly these issues concern the non-use of function results. These have been changed to use (void) pushJsonbValue(...) instead of assigning the result to a variable that gets overwritten before it is used. There is a larger issue that we should possibly examine the API for pushJsonbValue(), so that instead of returning a value it modifies a state argument. The current idiom is rather clumsy. However, changing that requires quite a bit more work, so this change should do for the moment.
* Misc comment typo fixes.Heikki Linnakangas2014-12-16
| | | | | Backpatch the applicable parts, just to make backpatching future patches easier.
* Fix incorrect comment about XLogRecordBlockHeader.data_length field.Heikki Linnakangas2014-12-16
| | | | | | | It does not include the possible full-page image. While at it, reformat the comment slightly to make it more readable. Reported by Rahila Syed
* Fix commit_ts test suite for systems with coarse timestamp granularity.Noah Misch2014-12-15
| | | | | | Noticed on a couple of Windows configurations. Petr Jelinek, reviewed by Michael Paquier.
* Translation updatesPeter Eisentraut2014-12-15
|
* add missing newlineAlvaro Herrera2014-12-15
|
* Fix point <-> polygon code for zero-distance case.Tom Lane2014-12-15
| | | | | "PG_RETURN_FLOAT8(x)" is not "return x", except perhaps by accident on some platforms.
* Add point <-> polygon distance operator.Heikki Linnakangas2014-12-15
| | | | Alexander Korotkov, reviewed by Emre Hasegeli.
* Translation updatesPeter Eisentraut2014-12-15
|
* Add CINE option for CREATE TABLE AS and CREATE MATERIALIZED VIEWAndrew Dunstan2014-12-13
| | | | Fabrízio de Royes Mello reviewed by Rushabh Lathia.
* Repair corner-case bug in array version of percentile_cont().Tom Lane2014-12-13
| | | | | | | | The code for advancing through the input rows overlooked the case that we might already be past the first row of the row pair now being considered, in case the previous percentile also fell between the same two input rows. Report and patch by Andrew Gierth; logic rewritten a bit for clarity by me.
* Remove duplicate #defineHeikki Linnakangas2014-12-13
| | | | Mark Dilger
* Avoid instability in output of new REINDEX SCHEMA test.Tom Lane2014-12-12
| | | | | | | | | | | | | The planner seems to like to do this join query as a hash join, making the output ordering machine-dependent; worse, it's a hash on OIDs, so that it's a bit astonishing that the result doesn't change from run to run even on one machine. Add an ORDER BY to get consistent results. Per buildfarm. I also suppressed output from the final DROP SCHEMA CASCADE, to avoid occasional failures similar to those fixed in commit 81d815dc3ed74a7d. That hasn't been observed in the buildfarm yet, but it seems likely to happen in future if we leave it as-is.
* Add several generator functions for jsonb that exist for json.Andrew Dunstan2014-12-12
| | | | | | | | | | | | | | | | The functions are: to_jsonb() jsonb_object() jsonb_build_object() jsonb_build_array() jsonb_agg() jsonb_object_agg() Also along the way some better logic is implemented in json_categorize_type() to match that in the newly implemented jsonb_categorize_type(). Andrew Dunstan, reviewed by Pavel Stehule and Alvaro Herrera.
* Add json_strip_nulls and jsonb_strip_nulls functions.Andrew Dunstan2014-12-12
| | | | | | | | The functions remove object fields, including in nested objects, that have null as a value. In certain cases this can lead to considerably smaller datums, with no loss of semantic information. Andrew Dunstan, reviewed by Pavel Stehule.
* Put the logic to decide which synchronous standby is active into a function.Heikki Linnakangas2014-12-12
| | | | | | This avoids duplicating the code. Michael Paquier, reviewed by Simon Riggs and me
* SSL tests: Remove trailing blank linesPeter Eisentraut2014-12-11
|
* SSL tests: Silence pg_ctl outputPeter Eisentraut2014-12-11
| | | | | Otherwise the pg_ctl start and stop messages get mixed up with the TAP output, which isn't technically valid.
* Fix planning of SELECT FOR UPDATE on child table with partial index.Tom Lane2014-12-11
| | | | | | | | | | | | | | | | | | | Ordinarily we can omit checking of a WHERE condition that matches a partial index's condition, when we are using an indexscan on that partial index. However, in SELECT FOR UPDATE we must include the "redundant" filter condition in the plan so that it gets checked properly in an EvalPlanQual recheck. The planner got this mostly right, but improperly omitted the filter condition if the index in question was on an inheritance child table. In READ COMMITTED mode, this could result in incorrectly returning just-updated rows that no longer satisfy the filter condition. The cause of the error is using get_parse_rowmark() when get_plan_rowmark() is what should be used during planning. In 9.3 and up, also fix the same mistake in contrib/postgres_fdw. It's currently harmless there (for lack of inheritance support) but wrong is wrong, and the incorrect code might get copied to someplace where it's more significant. Report and fix by Kyotaro Horiguchi. Back-patch to all supported branches.
* Fix corner case where SELECT FOR UPDATE could return a row twice.Tom Lane2014-12-11
| | | | | | | | | | | | | | | | In READ COMMITTED mode, if a SELECT FOR UPDATE discovers it has to redo WHERE-clause checking on rows that have been updated since the SELECT's snapshot, it invokes EvalPlanQual processing to do that. If this first occurs within a non-first child table of an inheritance tree, the previous coding could accidentally re-return a matching row from an earlier, already-scanned child table. (And, to add insult to injury, I think this could make it miss returning a row that should have been returned, if the updated row that this happens on should still have passed the WHERE qual.) Per report from Kyotaro Horiguchi; the added isolation test is based on his test case. This has been broken for quite awhile, so back-patch to all supported branches.
* Further changes to REINDEX SCHEMASimon Riggs2014-12-11
| | | | | | | | | | Ensure we reindex indexes built on Mat Views. Based on patch from Micheal Paquier Add thorough tests to check that indexes on tables, toast tables and mat views are reindexed. Simon Riggs
* Make rowsecurity test clean up after itself, too.Tom Lane2014-12-11
| | | | Leaving global objects like roles hanging around is bad practice.
* Fix completely broken REINDEX SCHEMA testcase.Tom Lane2014-12-11
| | | | | | | Aside from not testing the case it claimed to test (namely a permissions failure), it left a login-capable role lying around, which quite aside from possibly being a security hole would cause subsequent regression runs to fail since the role would already exist.
* Fix assorted confusion between Oid and int32.Tom Lane2014-12-11
| | | | | | | | | | | In passing, also make some debugging elog's in pgstat.c a bit more consistently worded. Back-patch as far as applicable (9.3 or 9.4; none of these mistakes are really old). Mark Dilger identified and patched the type violations; the message rewordings are mine.
* Use correct macro for reltablespace.Heikki Linnakangas2014-12-11
| | | | | | | It's an OID. WRITE_UINT_FIELD is identical to WRITE_OID_FIELD, but let's be tidy. Mark Dilger
* Fix typoPeter Eisentraut2014-12-10
| | | | Author: Fabrízio de Royes Mello <fabriziomello@gmail.com>
* Fix minor thinko in convertToJsonb().Tom Lane2014-12-10
| | | | | | | | | | The amount of space to reserve for the value's varlena header is VARHDRSZ, not sizeof(VARHDRSZ). The latter coding accidentally failed to fail because of the way the VARHDRSZ macro is currently defined; but if we ever change it to return size_t (as one might reasonably expect it to do), convertToJsonb() would have failed. Spotted by Mark Dilger.