aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* Windows: use GetSystemTimePreciseAsFileTime if availableSimon Riggs2014-12-08
| | | | | | | | | | | | | | PostgreSQL on Windows 8 or Windows Server 2012 will now get high-resolution timestamps by dynamically loading the GetSystemTimePreciseAsFileTime function. It'll fall back to to GetSystemTimeAsFileTime if the higher precision variant isn't found, so the same binaries without problems on older Windows releases. No attempt is made to detect the Windows version. Only the presence or absence of the desired function is considered. Craig Ringer
* Use GetSystemTimeAsFileTime directly in win32Simon Riggs2014-12-08
| | | | | | | | | | | | | | | | | | | | | | | | PostgreSQL was calling GetSystemTime followed by SystemTimeToFileTime in the win32 port gettimeofday function. This is not necessary and limits the reported precision to the 1ms granularity that the SYSTEMTIME struct can represent. By using GetSystemTimeAsFileTime we avoid unnecessary conversions and capture timestamps at 100ns granularity, which is then rounded to 1µs granularity for storage in a PostgreSQL timestamp. On most Windows systems this change will actually have no significant effect on timestamp resolution as the system timer tick is typically between 1ms and 15ms depending on what timer resolution currently running applications have requested. You can check this with clockres.exe from sysinternals. Despite the platform limiation this change still permits capture of finer timestamps where the system is capable of producing them and it gets rid of an unnecessary syscall. The higher resolution GetSystemTimePreciseAsFileTime call available on Windows 8 and Windows Server 2012 has the same interface as GetSystemTimeAsFileTime, so switching to GetSystemTimeAsFileTime makes it easier to use the Precise variant later. Craig Ringer, reviewed by David Rowley
* Remove duplicate code in heap_prune_chain()Simon Riggs2014-12-08
| | | | | | No need to set tuple tableOid twice Jim Nasby
* Event Trigger for table_rewriteSimon Riggs2014-12-08
| | | | | | | | | | | | | | Generate a table_rewrite event when ALTER TABLE attempts to rewrite a table. Provide helper functions to identify table and reason. Intended use case is to help assess or to react to schema changes that might hold exclusive locks for long periods. Dimitri Fontaine, triggering an edit by Simon Riggs Reviewed in detail by Michael Paquier
* Tweaks for recovery_target_actionSimon Riggs2014-12-07
| | | | | | | | | Rename parameter action_at_recovery_target to recovery_target_action suggested by Christoph Berg. Place into recovery.conf suggested by Fujii Masao, replacing (deprecating) earlier parameters, per Michael Paquier.
* Give a proper error message if initdb password file is empty.Heikki Linnakangas2014-12-05
| | | | | | | Used to say just "could not read password from file "...": Success", which isn't very informative. Mats Erik Andersson. Backpatch to all supported versions.
* Don't include file type bits in tar archive's mode field.Heikki Linnakangas2014-12-05
| | | | | | | | | | | | | | | | The "file mode" bits in the tar file header is not supposed to include the file type bits, e.g. S_IFREG or S_IFDIR. The file type is stored in a separate field. This isn't a problem in practice, all tar programs ignore the extra bits, but let's be tidy. This came up in a discussion around bug #11949, reported by Hendrik Grewe, although this doesn't fix the issue with tar --append. That turned out to be a bug in GNU tar. Schilly's tartest program revealed this defect in the tar created by pg_basebackup. This problem goes as far as we we've had pg_basebackup, but since this hasn't caused any problems in practice, let's be conservative and fix in master only.
* Remove erroneous EXTRA_CLEAN line from Makefile.Heikki Linnakangas2014-12-05
| | | | | | After commit da34731, these files are not generated files anymore. Adam Brightwell
* Print new track_commit_timestamp in rm_desc of a parameter-change record.Heikki Linnakangas2014-12-05
| | | | Michael Paquier
* Print wal_log_hints in the rm_desc routing of a parameter-change record.Heikki Linnakangas2014-12-05
| | | | | | | | | It was an oversight in the original commit. Also note in the sample config file that changing wal_log_hints requires a restart. Michael Paquier. Backpatch to 9.4, where wal_log_hints was added.
* Don't dump core if pq_comm_reset() is called before pq_init().Robert Haas2014-12-04
| | | | | | | This can happen if an error occurs in a standalone backend. This bug was introduced by commit 2bd9e412f92bc6a68f3e8bcb18e04955cc35001d. Reported by Álvaro Herrera.
* Fix PGXS vpath build when PostgreSQL is built with vpathPeter Eisentraut2014-12-04
| | | | | | PGXS computes srcdir from VPATH, PostgreSQL proper computes VPATH from srcdir, and doing both results in an error from make. Conditionalize so only one of these takes effect.
* Revert haphazard pgxs makefile changesPeter Eisentraut2014-12-04
| | | | | | These changes were originally submitted as "adds support for VPATH with USE_PGXS", but they are not necessary for VPATH support, so they just add more lines of code for no reason.
* Remove USE_VPATH make variable from PGXSPeter Eisentraut2014-12-04
| | | | | The user can just set VPATH directly. There is no need to invent another variable.
* Fix SHLIB_PREREQS use in contrib, allowing PGXS buildsPeter Eisentraut2014-12-04
| | | | | | | | | | | | | | | | dblink and postgres_fdw use SHLIB_PREREQS = submake-libpq to build libpq first. This doesn't work in a PGXS build, because there is no libpq to build. So just omit setting SHLIB_PREREQS in this case. Note that PGXS users can still use SHLIB_PREREQS (although it is not documented). The problem here is only that contrib modules can be built in-tree or using PGXS, and the prerequisite is only applicable in the former case. Commit 6697aa2bc25c83b88d6165340348a31328c35de6 previously attempted to address this by creating a somewhat fake submake-libpq target in Makefile.global. That was not the right fix, and it was also done in a nonportable way, so revert that.
* Move PG_AUTOCONF_FILENAME definitionPeter Eisentraut2014-12-03
| | | | | | | | | Since this is not something that a user should change, pg_config_manual.h was an inappropriate place for it. In initdb.c, remove the use of the macro, because utils/guc.h can't be included by non-backend code. But we hardcode all the other configuration file names there, so this isn't a disaster.
* Keep track of transaction commit timestampsAlvaro Herrera2014-12-03
| | | | | | | | | | | | | | | | | | | | | Transactions can now set their commit timestamp directly as they commit, or an external transaction commit timestamp can be fed from an outside system using the new function TransactionTreeSetCommitTsData(). This data is crash-safe, and truncated at Xid freeze point, same as pg_clog. This module is disabled by default because it causes a performance hit, but can be enabled in postgresql.conf requiring only a server restart. A new test in src/test/modules is included. Catalog version bumped due to the new subdirectory within PGDATA and a couple of new SQL functions. Authors: Álvaro Herrera and Petr Jelínek Reviewed to varying degrees by Michael Paquier, Andres Freund, Robert Haas, Amit Kapila, Fujii Masao, Jaime Casanova, Simon Riggs, Steven Singer, Peter Eisentraut
* Fix typosAlvaro Herrera2014-12-03
|
* Fix whitespacePeter Eisentraut2014-12-02
|
* Install kludges to fix check-world for src/test/modulesAlvaro Herrera2014-12-02
| | | | | | | | | | | | | | | | | | check-world failed in a completely clean tree, because src/test/modules fail to build unless errcodes.h is generated first. To fix this, install a dependency in src/test/modules' Makefile so that the necessary file is generated. Even with this, running "make check" within individual module subdirs will still fail because the dependency is not considered there, but this case is less interesting and would be messier to fix. check-world still failed with the above fix in place, this time because dummy_seclabel used LOAD to load the dynamic library, which doesn't work because the @libdir@ (expanded by the makefile) is expanded to the final install path, not the temporary installation directory used by make check. To fix, tweak things so that CREATE EXTENSION can be used instead, which solves the problem because the library path is expanded by the backend, which is aware of the true libdir.
* Improve error messages for malformed array input strings.Tom Lane2014-12-02
| | | | | | | | | | | | | | | Make the error messages issued by array_in() uniformly follow the style ERROR: malformed array literal: "actual input string" DETAIL: specific complaint here and rewrite many of the specific complaints to be clearer. The immediate motivation for doing this is a complaint from Josh Berkus that json_to_record() produced an unintelligible error message when dealing with an array item, because it tries to feed the JSON-format array value to array_in(). Really it ought to be smart enough to perform JSON-to-Postgres array conversion, but that's a future feature not a bug fix. In the meantime, this change is something we agreed we could back-patch into 9.4, and it should help de-confuse things a bit.
* Don't skip SQL backends in logical decoding for visibility computation.Andres Freund2014-12-02
| | | | | | | | | | | | | | | | | | The logical decoding patchset introduced PROC_IN_LOGICAL_DECODING flag PGXACT flag, that allows such backends to be skipped when computing the xmin horizon/snapshots. That's fine and sensible for walsenders streaming out logical changes, but not at all fine for SQL backends doing logical decoding. If the latter set that flag any change they have performed outside of logical decoding will not be regarded as visible - which e.g. can lead to that change being vacuumed away. Note that not setting the flag for SQL backends isn't particularly bothersome - the SQL backend doesn't do streaming, so it only runs for a limited amount of time. Per buildfarm member 'tick' and Alvaro. Backpatch to 9.4, where logical decoding was introduced.
* Fix JSON aggregates to work properly when final function is re-executed.Tom Lane2014-12-02
| | | | | | | | | | | | Davide S. reported that json_agg() sometimes produced multiple trailing right brackets. This turns out to be because json_agg_finalfn() attaches the final right bracket, and was doing so by modifying the aggregate state in-place. That's verboten, though unfortunately it seems there's no way for nodeAgg.c to check for such mistakes. Fix that back to 9.3 where the broken code was introduced. In 9.4 and HEAD, likewise fix json_object_agg(), which had copied the erroneous logic. Make some cosmetic cleanups as well.
* Minor cleanup of function declarations for BRIN.Tom Lane2014-12-02
| | | | | | | Get rid of PG_FUNCTION_INFO_V1() macros, which are quite inappropriate for built-in functions (possibly leftovers from testing as a loadable module?). Also, fix gratuitous inconsistency between SQL-level and C-level names of the minmax support functions.
* dummy_seclabel: add sql/, expected/, and .gitignoresAlvaro Herrera2014-12-02
| | | | Michael Paquier
* Guard against bad "dscale" values in numeric_recv().Tom Lane2014-12-01
| | | | | | | | | | | | | | | | | | | | | | | | We were not checking to see if the supplied dscale was valid for the given digit array when receiving binary-format numeric values. While dscale can validly be more than the number of nonzero fractional digits, it shouldn't be less; that case causes fractional digits to be hidden on display even though they're there and participate in arithmetic. Bug #12053 from Tommaso Sala indicates that there's at least one broken client library out there that sometimes supplies an incorrect dscale value, leading to strange behavior. This suggests that simply throwing an error might not be the best response; it would lead to failures in applications that might seem to be working fine today. What seems the least risky fix is to truncate away any digits that would be hidden by dscale. This preserves the existing behavior in terms of what will be printed for the transmitted value, while preventing subsequent arithmetic from producing results inconsistent with that. In passing, throw a specific error for the case of dscale being outside the range that will fit into a numeric's header. Before you got "value overflows numeric format", which is a bit misleading. Back-patch to all supported branches.
* Move security_label testAlvaro Herrera2014-12-01
| | | | | | | | Rather than have the core security_label regression test depend on the dummy_seclabel module, have that part of the test be executed by dummy_seclabel itself directly. This simplifies the testing rig a bit; in particular it should silence the problems from the MSVC buildfarm phylum, which haven't yet gotten taught how to install src/test/modules.
* Fix hstore_to_json_loose's detection of valid JSON number values.Andrew Dunstan2014-12-01
| | | | | | | | | | We expose a function IsValidJsonNumber that internally calls the lexer for json numbers. That allows us to use the same test everywhere, instead of inventing a broken test for hstore conversions. The new function is also used in datum_to_json, replacing the code that is now moved to the new function. Backpatch to 9.3 where hstore_to_json_loose was introduced.
* Put SSL_pending() call behind the new internal SSL API.Heikki Linnakangas2014-12-01
| | | | | It seems likely that any SSL implementation will need a similar call, not just OpenSSL.
* Add a #define for the inet overlaps operator.Tom Lane2014-11-30
| | | | | | Extracted from pending inet selectivity patch. The rest of it isn't quite ready to commit, but we might as well push this part so the patch doesn't have to track the moving target of pg_operator.h.
* Fix minor bugs in commit 30bf4689a96cd283af33edcdd6b7210df3f20cd8 et al.Tom Lane2014-11-30
| | | | | | | | | Coverity complained that the "else" added to fillPGconn() was unreachable, which it was. Remove the dead code. In passing, rearrange the tests so as not to bother trying to fetch values for options that can't be assigned. Pre-9.3 did not have that issue, but it did have a "return" that should be "goto oom_error" to ensure that a suitable error message gets filled in.
* Move test modules from contrib to src/test/modulesAlvaro Herrera2014-11-29
| | | | | | | | | | | | This is advance preparation for introducing even more test modules; the easy solution is to add them to contrib, but that's bloated enough that it seems a good time to think of something different. Moved modules are dummy_seclabel, test_shm_mq, test_parser and worker_spi. (test_decoding was also a candidate, but there was too much opposition to moving that one. We can always reconsider later.)
* Reimplement 9f80f4835a55a1cbffcda5d23a617917f3286c14 with PQconninfo().Noah Misch2014-11-29
| | | | | | | | Apart from ignoring "hostaddr" set to the empty string, this behaves identically to its predecessor. Back-patch to 9.4, where the original commit first appeared. Reviewed by Fujii Masao.
* Revert "Add libpq function PQhostaddr()."Noah Misch2014-11-29
| | | | | | | This reverts commit 9f80f4835a55a1cbffcda5d23a617917f3286c14. The function returned the raw value of a connection parameter, a task served by PQconninfo(). The next commit will reimplement the psql \conninfo change that way. Back-patch to 9.4, where that commit first appeared.
* Fix BRIN operator family definitionsAlvaro Herrera2014-11-28
| | | | | | | | | | | | The original definitions were leaving no room for cross-type operators, so queries that compared a column of one type against something of a different type were not taking advantage of the index. Fix by making the opfamilies more like the ones for Btree, and include a few cross-type operator classes. Catalog version bumped. Per complaints from Hubert Lubaczewski, Mark Wong, Heikki Linnakangas.
* Update transaction README for persistent multixactsAlvaro Herrera2014-11-28
| | | | | Multixacts are now maintained during recovery, but the README didn't get the memo. Backpatch to 9.3, where the divergence was introduced.
* Add bms_get_singleton_member(), and use it where appropriate.Tom Lane2014-11-28
| | | | | | | | | | This patch adds a function that replaces a bms_membership() test followed by a bms_singleton_member() call, performing both the test and the extraction of a singleton set's member in one scan of the bitmapset. The performance advantage over the old way is probably minimal in current usage, but it seems worthwhile on notational grounds anyway. David Rowley
* Add bms_next_member(), and use it where appropriate.Tom Lane2014-11-28
| | | | | | | | | | | | This patch adds a way of iterating through the members of a bitmapset nondestructively, unlike the old way with bms_first_member(). While bms_next_member() is very slightly slower than bms_first_member() (at least for typical-size bitmapsets), eliminating the need to palloc and pfree a temporary copy of the target bitmapset is a significant win. So this method should be preferred in all cases where a temporary copy would be necessary. Tom Lane, with suggestions from Dean Rasheed and David Rowley
* Improve performance of OverrideSearchPathMatchesCurrent().Tom Lane2014-11-28
| | | | | | | | | This function was initially coded on the assumption that it would not be performance-critical, but that turns out to be wrong in workloads that are heavily dependent on the speed of plpgsql functions. Speed it up by hard-coding the comparison rules, thereby avoiding palloc/pfree traffic from creating and immediately freeing an OverrideSearchPath object. Per report from Scott Marlowe.
* Improve typcache: cache negative lookup results, add invalidation logic.Tom Lane2014-11-28
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if the typcache had for example tried and failed to find a hash opclass for a given data type, it would nonetheless repeat the unsuccessful catalog lookup each time it was asked again. This can lead to a significant amount of useless bufmgr traffic, as in a recent report from Scott Marlowe. Like the catalog caches, typcache should be able to cache negative results. This patch arranges that by making use of separate flag bits to remember whether a particular item has been looked up, rather than treating a zero OID as an indicator that no lookup has been done. Also, install a credible invalidation mechanism, namely watching for inval events in pg_opclass. The sole advantage of the lack of negative caching was that the code would cope if operators or opclasses got added for a type mid-session; to preserve that behavior we have to be able to invalidate stale lookup results. Updates in pg_opclass should be pretty rare in production systems, so it seems sufficient to just invalidate all the dependent data whenever one happens. Adding proper invalidation also means that this code will now react sanely if an opclass is dropped mid-session. Arguably, that's a back-patchable bug fix, but in view of the lack of complaints from the field I'll refrain from back-patching. (Probably, in most cases where an opclass is dropped, the data type itself is dropped soon after, so that this misfeasance has no bad consequences.)
* Add tab-completion for ALTER TABLE ALTER CONSTRAINT in psql.Fujii Masao2014-11-28
| | | | | | Back-patch to 9.4 where ALTER TABLE ALTER CONSTRAINT was added. Michael Paquier, bug reported by Andrey Lizenko.
* Fix assertion failure at end of PITR.Heikki Linnakangas2014-11-28
| | | | | | | | | | | | | InitXLogInsert() cannot be called in a critical section, because it allocates memory. But CreateCheckPoint() did that, when called for the end-of-recovery checkpoint by the startup process. In the passing, fix the scratch space allocation in InitXLogInsert to go to the right memory context. Also update the comment at InitXLOGAccess, which hasn't been totally accurate since hot standby was introduced (in a hot standby backend, InitXLOGAccess isn't called at backend startup). Reported by Michael Paquier
* Make \watch respect the user's \pset null setting.Fujii Masao2014-11-28
| | | | | | | | | | | Previously \watch always ignored the user's \pset null setting. \pset null setting should be ignored for \d and similar queries. For those, the code can reasonably have an opinion about what the presentation should be like, since it knows what SQL query it's issuing. This argument surely doesn't apply to \watch, so this commit makes \watch use the user's \pset null setting. Back-patch to 9.3 where \watch was added.
* Mark response messages for translation in pg_isready.Fujii Masao2014-11-28
| | | | | | Back-patch to 9.3 where pg_isready was added. Mats Erik Andersson
* Rename pg_rowsecurity -> pg_policy and other fixesStephen Frost2014-11-27
| | | | | | | | | | | | | | | | | | | | | | | | | As pointed out by Robert, we should really have named pg_rowsecurity pg_policy, as the objects stored in that catalog are policies. This patch fixes that and updates the column names to start with 'pol' to match the new catalog name. The security consideration for COPY with row level security, also pointed out by Robert, has also been addressed by remembering and re-checking the OID of the relation initially referenced during COPY processing, to make sure it hasn't changed under us by the time we finish planning out the query which has been built. Robert and Alvaro also commented on missing OCLASS and OBJECT entries for POLICY (formerly ROWSECURITY or POLICY, depending) in various places. This patch fixes that too, which also happens to add the ability to COMMENT on policies. In passing, attempt to improve the consistency of messages, comments, and documentation as well. This removes various incarnations of 'row-security', 'row-level security', 'Row-security', etc, in favor of 'policy', 'row level security' or 'row_security' as appropriate. Happy Thanksgiving!
* Remove dead function prototypeHeikki Linnakangas2014-11-26
| | | | It was added in commit efc16ea5, but never defined.
* Attempt to suppress uninitialized variable warning.Robert Haas2014-11-25
| | | | Report by Heikki Linnakangas.
* Fix uninitialized-variable warning.Tom Lane2014-11-25
| | | | | | | In passing, add an Assert defending the presumption that bytes_left is positive to start with. (I'm not exactly convinced that using an unsigned type was such a bright thing here, but let's at least do this much.)
* action_at_recovery_target recovery config optionSimon Riggs2014-11-25
| | | | | | | | | action_at_recovery_target = pause | promote | shutdown Petr Jelinek Reviewed by Muhammad Asif Naeem, Fujji Masao and Simon Riggs
* De-reserve most statement-introducing keywords in plpgsql.Tom Lane2014-11-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a bit of context sensitivity to plpgsql_yylex() so that it can recognize when the word it is looking at is the first word of a new statement, and if so whether it is the target of an assignment statement. When we are at start of statement and it's not an assignment, we can prefer recognizing unreserved keywords over recognizing variable names, thereby allowing most statements' initial keywords to be demoted from reserved to unreserved status. This is rather useful already (there are 15 such words that get demoted here), and what's more to the point is that future patches proposing to add new plpgsql statements can avoid objections about having to add new reserved words. The keywords BEGIN, DECLARE, FOR, FOREACH, LOOP, WHILE need to remain reserved because they can be preceded by block labels, and the logic added here doesn't understand about block labels. In principle we could probably fix that, but it would take more than one token of lookback and the benefit doesn't seem worth extra complexity. Also note I didn't de-reserve EXECUTE, because it is used in more places than just statement start. It's possible it could be de-reserved with more work, but that would be an independent fix. In passing, also de-reserve COLLATE and DEFAULT, which shouldn't have been reserved in the first place since they only need to be recognized within DECLARE sections.