aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
...
* Drop no-longer-needed buffers during ALTER DATABASE SET TABLESPACE.Tom Lane2014-11-04
| | | | | | | | | | | | | The previous coding assumed that we could just let buffers for the database's old tablespace age out of the buffer arena naturally. The folly of that is exposed by bug #11867 from Marc Munro: the user could later move the database back to its original tablespace, after which any still-surviving buffers would match lookups again and appear to contain valid data. But they'd be missing any changes applied while the database was in the new tablespace. This has been broken since ALTER SET TABLESPACE was introduced, so back-patch to all supported branches.
* Switch to CRC-32C in WAL and other places.Heikki Linnakangas2014-11-04
| | | | | | | | | | | | | | | | | | | | | | | The old algorithm was found to not be the usual CRC-32 algorithm, used by Ethernet et al. We were using a non-reflected lookup table with code meant for a reflected lookup table. That's a strange combination that AFAICS does not correspond to any bit-wise CRC calculation, which makes it difficult to reason about its properties. Although it has worked well in practice, seems safer to use a well-known algorithm. Since we're changing the algorithm anyway, we might as well choose a different polynomial. The Castagnoli polynomial has better error-correcting properties than the traditional CRC-32 polynomial, even if we had implemented it correctly. Another reason for picking that is that some new CPUs have hardware support for calculating CRC-32C, but not CRC-32, let alone our strange variant of it. This patch doesn't add any support for such hardware, but a future patch could now do that. The old algorithm is kept around for tsquery and pg_trgm, which use the values in indexes that need to remain compatible so that pg_upgrade works. While we're at it, share the old lookup table for CRC-32 calculation between hstore, ltree and core. They all use the same table, so might as well.
* Remove support for 64-bit CRC.Heikki Linnakangas2014-11-04
| | | | It hasn't been used for anything for a long time.
* pqmq.h needs to include something that defines StringInfo.Robert Haas2014-11-03
| | | | Reported by Peter Eisentraut.
* Clarify .def file comments.Noah Misch2014-11-02
|
* Re-remove dependency on the DLL of pythonxx.def file.Noah Misch2014-11-02
| | | | | | | The reasons behind commit 0d147e43adcf5d2bff9caa073608f381a27439bf still stand, so this reverts the non-cosmetic portion of commit a7983e989d9cafc9cef49becfee054e34b1ed9b4. Back-patch to 9.4, where the latter commit first appeared.
* Make ECPG test programs depend on "ecpg$(X)", not "ecpg".Noah Misch2014-11-02
| | | | | | | | | Cygwin builds require this of dependencies pertaining to pattern rules. On Cygwin, stat("foo") in the absence of a file with that exact name can locate foo.exe. While GNU make uses stat() for dependencies of ordinary rules, it uses readdir() to assess dependencies of pattern rules. Therefore, a pattern rule dependency should match any underlying file name exactly. Back-patch to 9.4, where the dependency was introduced.
* Fix win32setlocale.c const-related warnings.Noah Misch2014-11-02
| | | | Back-patch to 9.2, like commit db29620d4d16e08241f965ccd70d0f65883ff0de.
* Add configure --enable-tap-tests optionPeter Eisentraut2014-11-02
| | | | | Don't skip the TAP tests anymore when IPC::Run is not found. This will fail normally now.
* Support frontend-backend protocol communication using a shm_mq.Robert Haas2014-10-31
| | | | | | | | | | | | | A background worker can use pq_redirect_to_shm_mq() to direct protocol that would normally be sent to the frontend to a shm_mq so that another process may read them. The receiving process may use pq_parse_errornotice() to parse an ErrorResponse or NoticeResponse from the background worker and, if it wishes, ThrowErrorData() to propagate the error (with or without further modification). Patch by me. Review by Andres Freund.
* Extend dsm API with a new function dsm_unpin_mapping.Robert Haas2014-10-30
| | | | | | | | | This reassociates a dynamic shared memory handle previous passed to dsm_pin_mapping with the current resource owner, so that it will be cleaned up at the end of the current query. Patch by me. Review of the function name by Andres Freund, Amit Kapila, Jim Nasby, Petr Jelinek, and Álvaro Herrera.
* Test IsInTransactionChain, not IsTransactionBlock, in vac_update_relstats.Tom Lane2014-10-30
| | | | | | | | | | | As noted by Noah Misch, my initial cut at fixing bug #11638 didn't cover all cases where ANALYZE might be invoked in an unsafe context. We need to test the result of IsInTransactionChain not IsTransactionBlock; which is notationally a pain because IsInTransactionChain requires an isTopLevel flag, which would have to be passed down through several levels of callers. I chose to pass in_outer_xact (ie, the result of IsInTransactionChain) rather than isTopLevel per se, as that seemed marginally more apropos for the intermediate functions to know about.
* "Pin", rather than "keep", dynamic shared memory mappings and segments.Robert Haas2014-10-30
| | | | | | | | | | Nobody seemed concerned about this naming when it originally went in, but there's a pending patch that implements the opposite of dsm_keep_mapping, and the term "unkeep" was judged unpalatable. "unpin" has existing precedent in the PostgreSQL code base, and the English language, so use this terminology instead. Per discussion, back-patch to 9.4.
* Remove use of TAP subtestsPeter Eisentraut2014-10-29
| | | | | They turned out to be too much of a portability headache, because they need a fairly new version of Test::More to work properly.
* Avoid corrupting tables when ANALYZE inside a transaction is rolled back.Tom Lane2014-10-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | VACUUM and ANALYZE update the target table's pg_class row in-place, that is nontransactionally. This is OK, more or less, for the statistical columns, which are mostly nontransactional anyhow. It's not so OK for the DDL hint flags (relhasindex etc), which might get changed in response to transactional changes that could still be rolled back. This isn't a problem for VACUUM, since it can't be run inside a transaction block nor in parallel with DDL on the table. However, we allow ANALYZE inside a transaction block, so if the transaction had earlier removed the last index, rule, or trigger from the table, and then we roll back the transaction after ANALYZE, the table would be left in a corrupted state with the hint flags not set though they should be. To fix, suppress the hint-flag updates if we are InTransactionBlock(). This is safe enough because it's always OK to postpone hint maintenance some more; the worst-case consequence is a few extra searches of pg_index et al. There was discussion of instead using a transactional update, but that would change the behavior in ways that are not all desirable: in most scenarios we're better off keeping ANALYZE's statistical values even if the ANALYZE itself rolls back. In any case we probably don't want to change this behavior in back branches. Per bug #11638 from Casey Shobe. This has been broken for a good long time, so back-patch to all supported branches. Tom Lane and Michael Paquier, initial diagnosis by Andres Freund
* Avoid setup work for invalidation messages at start-of-(sub)xact.Robert Haas2014-10-29
| | | | | | | | | | | | Instead of initializing a new TransInvalidationInfo for every transaction or subtransaction, we can just do it for those transactions or subtransactions that actually need to queue invalidation messages. That also avoids needing to free those entries at the end of a transaction or subtransaction that does not generate any invalidation messages, which is by far the common case. Patch by me. Review by Simon Riggs and Andres Freund.
* Reset error message at PQreset()Heikki Linnakangas2014-10-29
| | | | | | | | | If you call PQreset() repeatedly, and the connection cannot be re-established, the error messages from the failed connection attempts kept accumulating in the error string. Fixes bug #11455 reported by Caleb Epstein. Backpatch to all supported versions.
* Remove obsolete commentary.Tom Lane2014-10-28
| | | | | | | Since we got rid of non-MVCC catalog scans, the fourth reason given for using a non-transactional update in index_update_stats() is obsolete. The other three are still good, so we're not going to change the code, but fix the comment.
* Remove unnecessary assignment.Heikki Linnakangas2014-10-28
| | | | Reported by MauMau.
* MinGW: Include .dll extension in .def file LIBRARY commands.Noah Misch2014-10-27
| | | | | | | | | | | | | | | | | | Newer toolchains append the extension implicitly if missing, but buildfarm member narwhal (gcc 3.4.2, ld 2.15.91 20040904) does not. This affects most core libraries having an exports.txt file, namely libpq and the ECPG support libraries. On Windows Server 2003, Windows API functions that load and unload DLLs internally will mistakenly unload a libpq whose DLL header reports "LIBPQ" instead of "LIBPQ.dll". When, subsequently, control would return to libpq, the backend crashes. Back-patch to 9.4, like commit 846e91e0223cf9f2821c3ad4dfffffbb929cb027. Before that commit, we used a different linking technique that yielded "libpq.dll" in the DLL header. Commit 53566fc0940cf557416b13252df57350a4511ce4 worked around this by eliminating a call to a function that loads and unloads DLLs internally. That commit is no longer necessary for correctness, but its improving consistency with the MSVC build remains valid.
* Fix two bugs in tsquery @> operator.Heikki Linnakangas2014-10-27
| | | | | | | | | | | | | 1. The comparison for matching terms used only the CRC to decide if there's a match. Two different terms with the same CRC gave a match. 2. It assumed that if the second operand has more terms than the first, it's never a match. That assumption is bogus, because there can be duplicate terms in either operand. Rewrite the implementation in a way that doesn't have those bugs. Backpatch to all supported versions.
* Add variable names to two LWLock C prototypesBruce Momjian2014-10-27
| | | | Previously only the variable types appeared.
* Avoid unportable strftime() behavior in pg_dump/pg_dumpall.Tom Lane2014-10-26
| | | | | | | | | | | | | | Commit ad5d46a4494b0b480a3af246bb4227d9bdadca37 thought that we could get around the known portability issues of strftime's %Z specifier by using %z instead. However, that idea seems to have been innocent of any actual research, as it certainly missed the facts that (1) %z is not portable to pre-C99 systems, and (2) %z doesn't actually act differently from %Z on Windows anyway. Per failures on buildfarm member hamerkop. While at it, centralize the code defining what strftime format we want to use in pg_dump; three copies of that string seems a bit much.
* Fix undersized result buffer in pset_quoted_string().Tom Lane2014-10-26
| | | | | | | | | | | The malloc request was 1 byte too small for the worst-case output. This seems relatively unlikely to cause any problems in practice, as the worst case only occurs if the input string contains no characters other than single-quote or newline, and even then malloc alignment padding would probably save the day. But it's definitely a bug. David Rowley
* Improve planning of btree index scans using ScalarArrayOpExpr quals.Tom Lane2014-10-26
| | | | | | | | | | | | | | | | | | | | | | Since we taught btree to handle ScalarArrayOpExpr quals natively (commit 9e8da0f75731aaa7605cf4656c21ea09e84d2eb1), the planner has always included ScalarArrayOpExpr quals in index conditions if possible. However, if the qual is for a non-first index column, this could result in an inferior plan because we can no longer take advantage of index ordering (cf. commit 807a40c551dd30c8dd5a0b3bd82f5bbb1e7fd285). It can be better to omit the ScalarArrayOpExpr qual from the index condition and let it be done as a filter, so that the output doesn't need to get sorted. Indeed, this is true for the query introduced as a test case by the latter commit. To fix, restructure get_index_paths and build_index_paths so that we consider paths both with and without ScalarArrayOpExpr quals in non-first index columns. Redesign the API of build_index_paths so that it reports what it found, saving useless second or third calls. Report and patch by Andrew Gierth (though rather heavily modified by me). Back-patch to 9.2 where this code was introduced, since the issue can result in significant performance regressions compared to plans produced by 9.1 and earlier.
* Fix TAP tests with Perl 5.12Peter Eisentraut2014-10-26
| | | | | | | | | | | Perl 5.12 ships with a somewhat broken version of Test::Simple, so skip the tests if that is found. The relevant fix is 0.98 Wed, 23 Feb 2011 14:38:02 +1100 Bug Fixes * subtest() should not fail if $? is non-zero. (Aaron Crane)
* Fix TAP tests with Perl 5.8Peter Eisentraut2014-10-26
| | | | | | | | | | The prove program included in Perl 5.8 does not support the --ext option, so don't use that and use wildcards on the command line instead. Note that the tests will still all be skipped, because, for instance, the version of Test::More is too old, but at least the regular mechanisms for handling that will apply, instead of failing to call prove altogether.
* Add native compiler and memory barriers for solaris studio.Andres Freund2014-10-25
| | | | | Discussion: 20140925133459.GB9633@alap3.anarazel.de Author: Oskari Saarenmaa
* Work around Windows locale name with non-ASCII character.Heikki Linnakangas2014-10-24
| | | | | | | | | | | | | | | | | | | | | | Windows has one a locale whose name contains a non-ASCII character: "Norwegian (Bokmål)" (that's an 'a' with a ring on top). That causes trouble; when passing it setlocale(), it's not clear what encoding the argument should be in. Another problem is that the locale name is stored in pg_database catalog table, and the encoding used there depends on what server encoding happens to be in use when the database is created. For example, if you issue the CREATE DATABASE when connected to a UTF-8 database, the locale name is stored in pg_database in UTF-8. As long as all locale names are pure ASCII, that's not a problem. To work around that, map the troublesome locale name to a pure-ASCII alias of the same locale, "norwegian-bokmal". Now, this doesn't change the existing values that are already in pg_database and in postgresql.conf. Old clusters will need to be fixed manually. Instructions for that need to be put in the release notes. This fixes bug #11431 reported by Alon Siman-Tov. Backpatch to 9.2; backpatching further would require more work than seems worth it.
* Forgot #include "pg_getopt.h", now that pg_controldata uses getopt.Heikki Linnakangas2014-10-24
| | | | Needed at least on Windows.
* Complain if too many options are passed to pg_controldata or pg_resetxlog.Heikki Linnakangas2014-10-24
|
* Oops, the commit accept pg_controldata -D datadir missed code changes.Heikki Linnakangas2014-10-24
| | | | | | | I updated the docs and usage blurp, but forgot to commit the code changes required. Spotted by Michael Paquier.
* Fix off-by-one error in 2781b4bea7db357be59f9a5fd73ca1eb12ff5a79.Robert Haas2014-10-24
| | | | Spotted by Tom Lane.
* psql: complain if pg_dump custom-format is detectedAlvaro Herrera2014-10-24
| | | | | | | | | | Apparently, this is a very common mistake for users to make; it is better to have it fail reasonably rather than throw potentially a large number of errors. Since we have a magic string at the start of the file, we can detect the case easily and there's no other possible useful behavior anyway. Author: Craig Ringer
* Update README.tuplockAlvaro Herrera2014-10-23
| | | | | | | This file was documenting an older version of patch 0ac5ad5134; update it to match what was really committed Author: Florian Pflug
* In type_sanity, check I/O functions of built-in types are not volatile.Tom Lane2014-10-23
| | | | | | | | | | | | | | We have a project policy that I/O functions must not be volatile, as per commit aab353a60b95aadc00f81da0c6d99bde696c4b75, but we weren't doing anything to enforce that. In most usage the marking of the function doesn't matter as long as its behavior is sane --- but I/O casts can expose the marking as user-visible behavior, as per today's complaint from Joe Van Dyk about contrib/ltree. This test as such will only protect us against future errors in built-in data types. To catch the same error in contrib or third-party types, perhaps we should make CREATE TYPE complain? But that's a separate issue from enforcing the policy for built-in types.
* Improve ispell dictionary's defenses against bad affix files.Tom Lane2014-10-23
| | | | | | | | | | | | | Don't crash if an ispell dictionary definition contains flags but not any compound affixes. (This isn't a security issue since only superusers can install affix files, but still it's a bad thing.) Also, be more careful about detecting whether an affix-file FLAG command is old-format (ispell) or new-format (myspell/hunspell). And change the error message about mixed old-format and new-format commands into something intelligible. Per bug #11770 from Emre Hasegeli. Back-patch to all supported branches.
* Perform less setup work for AFTER triggers at transaction start.Robert Haas2014-10-23
| | | | | | | | | | Testing reveals that the memory allocation we do at transaction start has small but measurable overhead on simple transactions. To cut down on that overhead, defer some of that work to the point when AFTER triggers are first used, thus avoiding it altogether if they never are. Patch by me. Review by Andres Freund.
* Remove the unused argument of PSQLexec().Fujii Masao2014-10-23
| | | | | | | | This commit simply removes the second argument of PSQLexec that was set to the same value everywhere. Comments and code blocks related to this parameter are removed. Noticed by Heikki Linnakangas, reviewed by Michael Paquier
* Add a function to get the authenticated user ID.Robert Haas2014-10-23
| | | | | | | | Previously, this was not exposed outside of miscinit.c. It is needed for the pending pg_background patch, and will also be needed for parallelism. Without it, there's no way for a background worker to re-create the exact authentication environment that was present in the process that started it, which could lead to security exposures.
* Prevent the already-archived WAL file from being archived again.Fujii Masao2014-10-23
| | | | | | | | | | | | | | | | | | Previously the archive recovery always created .ready file for the last WAL file of the old timeline at the end of recovery even when it's restored from the archive and has .done file. That is, there was the case where the WAL file had both .ready and .done files. This caused the already-archived WAL file to be archived again. This commit prevents the archive recovery from creating .ready file for the last WAL file if it has .done file, in order to prevent it from being archived again. This bug was added when cascading replication feature was introduced, i.e., the commit 5286105800c7d5902f98f32e11b209c471c0c69c. So, back-patch to 9.2, where cascading replication was added. Reviewed by Michael Paquier
* Minimize calls of pg_class_aclcheck to minimum necessaryPeter Eisentraut2014-10-22
| | | | | | | | | | In a couple of code paths, pg_class_aclcheck is called in succession with multiple different modes set. This patch combines those modes to have a single call of this function and reduce a bit process overhead for permission checking. Author: Michael Paquier <michael@otacoo.com> Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
* Add tests for sequence privilegesPeter Eisentraut2014-10-22
|
* Ensure libpq reports a suitable error message on unexpected socket EOF.Tom Lane2014-10-22
| | | | | | | | | | | | | The EOF-detection logic in pqReadData was a bit confused about who should set up the error message in case the kernel gives us read-ready-but-no-data rather than ECONNRESET or some other explicit error condition. Since the whole point of this situation is that the lower-level functions don't know there's anything wrong, pqReadData itself must set up the message. But keep the assumption that if an errno was reported, a message was set up at lower levels. Per bug #11712 from Marko Tiikkaja. It's been like this for a very long time, so back-patch to all supported branches.
* Small code cleanup.Michael Meskes2014-10-22
| | | | Declare static variable as static and external as extern.
* Update comment.Heikki Linnakangas2014-10-22
| | | | | | | The _bt_tuplecompare() function mentioned in comment hasn't existed for a long time. Peter Geoghegan
* MinGW: Use -static-libgcc when linking a DLL.Noah Misch2014-10-21
| | | | | | | | | When commit 846e91e0223cf9f2821c3ad4dfffffbb929cb027 switched the linker driver from dlltool/dllwrap to gcc, it became possible for linking to choose shared libgcc. Backends having loaded a module dynamically linked to libgcc can exit abnormally, which the postmaster treats like a crash. Resume use of static libgcc exclusively, like 9.3 and earlier. Back-patch to 9.4.
* MinGW: Link with shell32.dll instead of shfolder.dll.Noah Misch2014-10-21
| | | | | | | | | | | This improves consistency with the MSVC build. On buildfarm member narwhal, since commit 846e91e0223cf9f2821c3ad4dfffffbb929cb027, shfolder.dll:SHGetFolderPath() crashes when dblink calls it by way of pqGetHomeDirectory(). Back-patch to 9.4, where that commit first appeared. How it caused this regression remains a mystery. This is a partial revert of commit 889f03812916b146ae504c0fad5afdc7bf2e8a2a, which adopted shfolder.dll for Windows NT 4.0 compatibility. PostgreSQL 8.2 dropped support for that operating system.
* Update expected/sequence_1.out.Tom Lane2014-10-21
| | | | | | | The last three updates to the sequence regression test have all forgotten to touch the alternate expected-output file. Sigh. Michael Paquier
* Allow input format xxxx-xxxx-xxxx for macaddr typePeter Eisentraut2014-10-21
| | | | | Author: Herwin Weststrate <herwin@quarantainenet.nl> Reviewed-by: Ali Akbar <the.apaan@gmail.com>