summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2015-07-08Given a gcc-compatible xlc compiler, prefer xlc-style atomics.Noah Misch
This evades a ppc64le "IBM XL C/C++ for Linux" compiler bug. Back-patch to 9.5, where the atomics facility was introduced.
2015-07-08Finish generic-xlc.h draft atomics implementation.Noah Misch
Back-patch to 9.5, where commit b64d92f1a5602c55ee8b27a7ac474f03b7aee340 introduced this file.
2015-07-08Revoke support for strxfrm() that write past the specified array length.Noah Misch
This formalizes a decision implicit in commit 4ea51cdfe85ceef8afabceb03c446574daa0ac23 and adds clean detection of affected systems. Vendor updates are available for each such known bug. Back-patch to 9.5, where the aforementioned commit first appeared.
2015-07-08Replace use of "diff -q".Noah Misch
POSIX does not specify the -q option, and many implementations do not offer it. Don't bother changing the MSVC build system, because having non-GNU diff on Windows is vanishingly unlikely. Back-patch to 9.2, where this invocation was introduced.
2015-07-08Fix null pointer dereference in "\c" psql command.Noah Misch
The psql crash happened when no current connection existed. (The second new check is optional given today's undocumented NULL argument handling in PQhost() etc.) Back-patch to 9.0 (all supported versions).
2015-07-07Improve regression test coverage of table lock modes vs permissions.Joe Conway
Test the interactions with permissions and LOCK TABLE. Specifically ROW EXCLUSIVE, ACCESS SHARE, and ACCESS EXCLUSIVE modes against SELECT, INSERT, UPDATE, DELETE, and TRUNCATE permissions. Discussed by Stephen Frost and Michael Paquier, patch by the latter. Backpatch to 9.5 where matching behavior was first committed.
2015-07-08Fix incorrect path in pg_regress log messages.Fujii Masao
Back-patch to 9.5 where the bug was introduced. David Christensen
2015-07-07Fix portability issue in pg_upgrade test script: avoid $PWD.Tom Lane
SUSv2-era shells don't set the PWD variable, though anything more modern does. In the buildfarm environment this could lead to test.sh executing with PWD pointing to $HOME or another high-level directory, so that there were conflicts between concurrent executions of the test in different branch subdirectories. This appears to be the explanation for recent intermittent failures on buildfarm members binturong and dingo (and might well have something to do with the buildfarm script's failure to capture log files from pg_upgrade tests, too). To fix, just use `pwd` in place of $PWD. AFAICS test.sh is the only place in our source tree that depended on $PWD. Back-patch to all versions containing this script. Per buildfarm. Thanks to Oskari Saarenmaa for diagnosing the problem.
2015-07-07Improve handling of out-of-memory in libpq.Heikki Linnakangas
If an allocation fails in the main message handling loop, pqParseInput3 or pqParseInput2, it should not be treated as "not enough data available yet". Otherwise libpq will wait indefinitely for more data to arrive from the server, and gets stuck forever. This isn't a complete fix - getParamDescriptions and getCopyStart still have the same issue, but it's a step in the right direction. Michael Paquier and me. Backpatch to all supported versions.
2015-07-07Add tab-completion for psql meta-commands.Fujii Masao
Based on the original code from David Christensen, modified by me.
2015-07-07Add psql PROMPT variable showing the pid of the connected to backend.Andres Freund
The substitution for the pid is %p. Author: Julien Rouhaud Discussion: 116262CF971C844FB6E793F8809B51C6E99D48@BPXM02GP.gisp.nec.co.jp
2015-07-07Fix logical decoding bug leading to inefficient reopening of files.Andres Freund
When spilling transaction data to disk a simple typo caused the output file to be closed and reopened for every serialized change. That happens to not have a huge impact on linux, which is why it probably wasn't noticed so far, but on windows that appears to trigger actual disk writes after every change. Not fun. The bug fortunately does not have any impact besides speed. A change could end up being in the wrong segment (last instead of next), but since we read all files to the end, that's just ugly, not really problematic. It's not a problem to upgrade, since transaction spill files do not persist across restarts. Bug: #13484 Reported-By: Olivier Gosseaume Discussion: 20150703090217.1190.63940@wrigleys.postgresql.org Backpatch to 9.4, where logical decoding was added.
2015-07-07Fix pg_recvlogical not to fsync output when it's a tty or pipe.Andres Freund
The previous coding tried to handle possible failures when fsyncing a tty or pipe fd by accepting EINVAL - but apparently some platforms (windows, OSX) don't reliably return that. So instead check whether the output fd refers to a pipe or a tty when opening it. Reported-By: Olivier Gosseaume, Marko Tiikkaja Discussion: 559AF98B.3050901@joh.to Backpatch to 9.4, where pg_recvlogical was added.
2015-07-06Make RLS related error messages more consistent and compliant.Joe Conway
Also updated regression expected output to match. Noted and patch by Daniele Varrazzo.
2015-07-06Turn install.bat into a pure one line wrapper fort he perl script.Heikki Linnakangas
Build.bat and vcregress.bat got similar treatment years ago. I'm not sure why install.bat wasn't treated at the same time, but it seems like a good idea anyway. The immediate problem with the old install.bat was that it had quoting issues, and wouldn't work if the target directory's name contained spaces. This fixes that problem.
2015-07-06Call getsockopt() on the correct socket.Heikki Linnakangas
We're interested in the buffer size of the socket that's connected to the client, not the one that's listening for new connections. It happened to work, as default buffer size is the same on both, but it was clearly not wrong. Spotted by Tom Lane
2015-07-06Don't set SO_SNDBUF on recent Windows versions that have a bigger default.Heikki Linnakangas
It's unnecessary to set it if the default is higher in the first place. Furthermore, setting SO_SNDBUF disables the so-called "dynamic send buffering" feature, which hurts performance further. This can be seen especially when the network between the client and the server has high latency. Chen Huajun
2015-07-05Make a editorial pass over pgbench's error messages.Tom Lane
The lack of consistency, and lack of attention to our message style guidelines, was a bit striking. Try to make 'em better.
2015-07-05Fix some typos in regression test comments.Tom Lane
Back-patch to avoid unnecessary cross-branch differences. CharSyam
2015-07-05Further reduce overhead for passing plpgsql variables to the executor.Tom Lane
This builds on commit 21dcda2713656a7483e3280ac9d2ada20a87a9a9 by keeping a plpgsql function's shared ParamListInfo's entries for simple variables (PLPGSQL_DTYPE_VARs) valid at all times. That adds a few cycles to each assignment to such variables, but saves significantly more cycles each time they are used; so except in the pathological case of many dead stores, this should always be a win. Initial testing says it's good for about a 10% speedup of simple calculations; more in large functions with many datums. We can't use this method for row/record references unfortunately, so what we do for those is reset those ParamListInfo slots after use; which we can skip doing unless some of them were actually evaluated during the previous evaluation call. So this should frequently be a win as well, while worst case is that it's similar cost to the previous approach. Also, closer study suggests that the previous method of instantiating a new ParamListInfo array per evaluation is actually probably optimal for cursor-opening executor calls. The reason is that whatever is visible in the array is going to get copied into the cursor portal via copyParamList. So if we used the function's main ParamListInfo for those calls, we'd end up with all of its DTYPE_VAR vars getting copied, which might well include large pass-by-reference values that the cursor actually has no need for. To avoid a possible net degradation in cursor cases, go back to creating and filling a private ParamListInfo in those cases (which therefore will be exactly the same speed as before 21dcda271365). We still get some benefit out of this though, because this approach means that we only have to defend against copyParamList's try-to-fetch-every-slot behavior in the case of an unshared ParamListInfo; so plpgsql_param_fetch() can skip testing expr->paramnos in the common case. To ensure that the main ParamListInfo's image of a DTYPE_VAR datum is always valid, all assignments to such variables are now funneled through assign_simple_var(). But this makes for cleaner and shorter code anyway.
2015-07-03Add documentation and regression tests concerning rounding of numerics.Tom Lane
Michael Paquier, reviewed by Fabien Coelho
2015-07-03Add psql \ev and \sv commands for editing and showing view definitions.Tom Lane
These are basically just like the \ef and \sf commands for functions. Petr Korobeinikov, reviewed by Jeevan Chalke, some changes by me
2015-07-03Remove thread-emulation support from pgbench.Heikki Linnakangas
You can no longer use pgbench with multiple threads when compiled without --enable-thread-safety. That's an acceptable limitation these days; it still works fine with -j1, and all modern platforms support threads anyway. This makes future maintenance and development of the code easier. Fabien Coelho
2015-07-03Fix pgbench progress report behaviour when pgbench or a query gets stuck.Heikki Linnakangas
There were two issues here. First, if a query got stuck so that it took e.g. 5 seconds, and progress interval was 1 second, no progress reports were printed until the query returned. Fix so that we wake up specifically to print the progress report. Secondly, if pgbench got stuck so that it would nevertheless not print a progress report on time, and enough time passes that it's already time to print the next progress report, just skip the one that was missed. Before this patch, it would print the missed one with 0 TPS immediately after the previous one. Fabien Coelho. Backpatch to 9.4, where progress reports were added.
2015-07-03Lift the limitation that # of clients must be a multiple of # of threadsHeikki Linnakangas
Fabien Coelho
2015-07-03Make WAL-related utilities handle .partial WAL files properly.Fujii Masao
Commit de76884 changed an archive recovery so that the last WAL segment with old timeline was renamed with suffix .partial. It should have updated WAL-related utilities so that they can handle such .paritial WAL files, but we forgot that. This patch changes pg_archivecleanup so that it can clean up even archived WAL files with .partial suffix. Also it allows us to specify .partial WAL file name as the command-line argument "oldestkeptwalfile". This patch also changes pg_resetxlog so that it can remove .partial WAL files in pg_xlog directory. pg_xlogdump cannot handle .partial WAL files. Per discussion, we decided only to document that limitation instead of adding the fix. Because a user can easily work around the limitation (i.e., just remove .partial suffix from the file name) and the fix seems complicated for very narrow use case. Back-patch to 9.5 where the problem existed. Review by Michael Paquier. Discussion: http://www.postgresql.org/message-id/CAHGQGwGxMKnVHGgTfiig2Bt_2djec0in3-DLJmtg7+nEiidFdQ@mail.gmail.com
2015-07-02Improve pg_restore's -t switch to match all types of relations.Tom Lane
-t will now match views, foreign tables, materialized views, and sequences, not only plain tables. This is more useful, and also more consistent with the behavior of pg_dump's -t switch, which has always matched all relation types. We're still not there on matching pg_dump's behavior entirely, so mention that in the docs. Craig Ringer, reviewed by Pavel Stehule
2015-07-02Make numeric form of PG version number readily available in Makefiles.Tom Lane
Expose PG_VERSION_NUM (e.g., "90600") as a Make variable; but for consistency with the other Make variables holding similar info, call the variable just VERSION_NUM not PG_VERSION_NUM. There was some discussion of making this value available as a pg_config value as well. However, that would entail substantially more work than this two-line patch. Given that there was not exactly universal consensus that we need this at all, let's just do a minimal amount of work for now. Michael Paquier, reviewed by Pavel Stehule
2015-07-02Fix misuse of TextDatumGetCString().Tom Lane
"TextDatumGetCString(PG_GETARG_TEXT_P(x))" is formally wrong: a text* is not a Datum. Although this coding will accidentally fail to fail on all known platforms, it risks leaking memory if a detoast step is needed, unlike "TextDatumGetCString(PG_GETARG_DATUM(x))" which is what's used elsewhere. Make pg_get_object_address() fall in line with other uses. Noted while reviewing two-arg current_setting() patch.
2015-07-02Add an optional missing_ok argument to SQL function current_setting().Tom Lane
This allows convenient checking for existence of a GUC from SQL, which is particularly useful when dealing with custom variables. David Christensen, reviewed by Jeevan Chalke
2015-07-02Remove obsolete heap_formtuple/modifytuple/deformtuple functions.Heikki Linnakangas
These variants used the old-style 'n'/' ' NULL indicators. The new-style functions have been available since version 8.1. That should be long enough that if there is still any old external code using these functions, they can just switch to the new functions without worrying about backwards compatibility Peter Geoghegan
2015-07-02Remove "const" from convertTSFunction()'s return type.Heikki Linnakangas
There's no particular reason to mark it as such. The other convert* functions have no const either.
2015-07-02Plug some trivial memory leaks in pg_dump and pg_upgrade.Heikki Linnakangas
There's no point in trying to free every small allocation in these programs that are used in a one-shot fashion, but these ones seems like an improvement on readability grounds. Michael Paquier, per Coverity report.
2015-07-02Whitespace fix - replace tab with spaces in CREATE TABLE command.Joe Conway
2015-07-02Don't emit a spurious space at end of line in pg_dump of event triggers.Heikki Linnakangas
Backpatch to 9.3 and above, where event triggers were added.
2015-07-02Use appendStringInfoString/Char et al where appropriate.Heikki Linnakangas
Patch by David Rowley. Backpatch to 9.5, as some of the calls were new in 9.5, and keeping the code in sync with master makes future backpatching easier.
2015-07-02Fix name of argument to pg_stat_file.Heikki Linnakangas
It's called "missing_ok" in the docs and in the C code. I refrained from doing a catversion bump for this, because the name of an input argument is just documentation, it has no effect on any callers. Michael Paquier
2015-07-01Allow MSVC's contribcheck and modulescheck to run independently.Andrew Dunstan
These require a temp install to have been done, so we now make sure it is done before proceeding. Michael Paquier.
2015-07-02Make use of xlog_internal.h's macros in WAL-related utilities.Fujii Masao
Commit 179cdd09 added macros to check if a filename is a WAL segment or other such file. However there were still some instances of the strlen + strspn combination to check for that in WAL-related utilities like pg_archivecleanup. Those checks can be replaced with the macros. This patch makes use of the macros in those utilities and which would make the code a bit easier to read. Back-patch to 9.5. Michael Paquier
2015-07-01Don't leave pg_hba and pg_ident data lying around in running backends.Tom Lane
Free the contexts holding this data after we're done using it, by the expedient of attaching them to the PostmasterContext which we were already taking care to delete (and where, indeed, this data used to live before commits e5e2fc842c418432 and 7c45e3a3c682f855). This saves a probably-usually-negligible amount of space per running backend. It also avoids leaving potentially-security-sensitive data lying around in memory in processes that don't need it. You'd have to be unusually paranoid to think that that amounts to a live security bug, so I've not gone so far as to forcibly zero the memory; but there surely isn't a good reason to keep this data around. Arguably this is a memory management bug in the aforementioned commits, but it doesn't seem important enough to back-patch.
2015-07-01Make sampler_random_fract() actually obey its API contract.Tom Lane
This function is documented to return a value in the range (0,1), which is what its predecessor anl_random_fract() did. However, the new version depends on pg_erand48() which returns a value in [0,1). The possibility of returning zero creates hazards of division by zero or trying to compute log(0) at some call sites, and it might well break third-party modules using anl_random_fract() too. So let's change it to never return zero. Spotted by Coverity. Michael Paquier, cosmetically adjusted by me
2015-07-01Make XLogFileCopy() look the same as in 9.4.Fujii Masao
XLogFileCopy() was changed heavily in commit de76884. However it was partially reverted in commit 7abc685 and most of those changes to XLogFileCopy() were no longer needed. Then commit 7cbee7c removed those unnecessary code, but XLogFileCopy() looked different in master and 9.4 though the contents are almost the same. This patch makes XLogFileCopy() look the same in master and back-branches, which makes back-patching easier, per discussion on pgsql-hackers. Back-patch to 9.5. Discussion: 55760844.7090703@iki.fi Michael Paquier
2015-06-30Stamp shared-library minor version numbers for 9.6.Tom Lane
2015-06-30Stamp HEAD as 9.6devel.Tom Lane
Let the hacking begin ...
2015-06-30Remove useless check for NULL subexpression.Tom Lane
Coverity rightly gripes that it's silly to have a test here when the adjacent ExecEvalExpr() would choke on a NULL expression pointer. Petr Jelinek
2015-06-30Add assertion to check the special size is sane before dereferencing it.Heikki Linnakangas
This seems useful to catch errors of the sort I just fixed, where PageGetSpecialPointer is called before initializing the page.
2015-06-30Don't call PageGetSpecialPointer() on page until it's been initialized.Heikki Linnakangas
After calling XLogInitBufferForRedo(), the page might be all-zeros if it was not in page cache already. btree_xlog_unlink_page initialized the page correctly, but it called PageGetSpecialPointer before initializing it, which would lead to a corrupt page at WAL replay, if the unlinked page is not in page cache. Backpatch to 9.4, the bug came with the rewrite of B-tree page deletion.
2015-06-29In bttext_abbrev_convert, move pfree to the right place.Robert Haas
Without this, we might access memory that's already been freed, or leak memory if in the C locale. Peter Geoghegan
2015-06-30Initialize GIN metapage correctly when replaying metapage-update WAL record.Heikki Linnakangas
I broke this with my WAL format refactoring patch. Before that, the metapage was read from disk, and modified in-place regardless of the LSN. That was always a bit silly, as there's no need to read the old page version from disk disk when we're overwriting it anyway. So that was changed in 9.5, but I failed to add a GinInitPage call to initialize the page-headers correctly. Usually you wouldn't notice, because the metapage is already in the page cache and is not zeroed. One way to reproduce this is to perform a VACUUM on an already vacuumed table (so that the vacuum has no real work to do), immediately after a checkpoint, and then perform an immediate shutdown. After recovery, the page headers of the metapage will be incorrectly all-zeroes. Reported by Jeff Janes
2015-06-29Stamp 9.5alpha1.REL9_5_ALPHA1Tom Lane