summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2013-03-01Exclude utils/probes.h and pg_trace.h from cpluspluscheckPeter Eisentraut
They can include sys/sdt.h from SystemTap, which itself contains C++ code and so won't compile with a C++ compiler under extern "C" linkage.
2013-03-01Eliminate memory leaks in plperl's spi_prepare() function.Tom Lane
Careless use of TopMemoryContext for I/O function data meant that repeated use of spi_prepare and spi_freeplan would leak memory at the session level, as per report from Christian Schröder. In addition, spi_prepare leaked a lot of transient data within the current plperl function's SPI Proc context, which would be a problem for repeated use of spi_prepare within a single plperl function call; and it wasn't terribly careful about releasing permanent allocations in event of an error, either. In passing, clean up some copy-and-pasteos in query-lookup error messages. Alex Hunsaker and Tom Lane
2013-02-27Flush stderr and stdout in isolation tester.Andrew Dunstan
This is a possibly vain attempt to fix a buffering issue observed for some MSVC builds.
2013-02-27Fix MSVC build.Heikki Linnakangas
The new file in src/port needs to be listed in Mkvcbuild.pm as well.
2013-02-27Cannot use WL_SOCKET_WRITEABLE without WL_SOCKET_READABLE.Heikki Linnakangas
In copy-out mode, the frontend should not send any messages until the backend has finished streaming, by sending a CopyDone message. I'm not sure if it would be legal for the client to send a new query before receiving the CopyDone message from the backend, but trying to support that would require bigger changes to the backend code structure. Fixes an assertion failure reported by Fujii Masao.
2013-02-27Add standard file header comment to quotes.c.Heikki Linnakangas
2013-02-27Add support for piping COPY to/from an external program.Heikki Linnakangas
This includes backend "COPY TO/FROM PROGRAM '...'" syntax, and corresponding psql \copy syntax. Like with reading/writing files, the backend version is superuser-only, and in the psql version, the program is run in the client. In the passing, the psql \copy STDIN/STDOUT syntax is subtly changed: if you the stdin/stdout is quoted, it's now interpreted as a filename. For example, "\copy foo from 'stdin'" now reads from a file called 'stdin', not from standard input. Before this, there was no way to specify a filename called stdin, stdout, pstdin or pstdout. This creates a new function in pgport, wait_result_to_str(), which can be used to convert the exit status of a process, as returned by wait(3), to a human-readable string. Etsuro Fujita, reviewed by Amit Kapila.
2013-02-27Add missing error check in regexp parser.Tom Lane
parseqatom() failed to check for an error return (NULL result) from its recursive call to parsebranch(), and in consequence could crash with a null-pointer dereference after an error return. This bug has been there since day one, but wasn't noticed before, probably because most error cases in parsebranch() didn't actually lead to returning NULL. Add the missing error check, and also tweak parsebranch() to exit in a less indirect fashion after a call to parseqatom() fails. Report by Tomasz Karlik, fix by me.
2013-02-26Install headers from the new src/include/common subdirectory.Tom Lane
This got missed in commit 8396447cdbdff0b62914748de2fec04281dc9114. Andres Freund
2013-02-26Remove the check for COPY TO STDIN and COPY FROM STDOUT from ecpg.Heikki Linnakangas
The backend grammar treats STDIN and STDOUT completely interchangeable, so that the above accepted. Arguably that was a mistake the backend grammar, but it's not ecpg's business to second guess that.
2013-02-25Only quote libpq connection string values that need quoting.Heikki Linnakangas
There's no harm in excessive quoting per se, but it makes the strings nicer to read. The values can get quite unwieldy, when they're first quoted within within single-quotes when included in the connection string, and then all the single-quotes are escaped when the connection string is passed as a shell argument.
2013-02-25Add -d option to pg_dumpall, for specifying a connection string.Heikki Linnakangas
Like with pg_basebackup and pg_receivexlog, it's a bit strange to call the option -d/--dbname, when in fact you cannot pass a database name in it. Original patch by Amit Kapila, heavily modified by me.
2013-02-25Add -d/--dbname option to pg_dump.Heikki Linnakangas
You could already pass a database name just by passing it as the last option, without -d. This is an alias for that, like the -d/--dbname option in psql and many other client applications. For consistency.
2013-02-25Redo MSVC build implementation for pg_xlogdump.Andrew Dunstan
The previous commit didn't work on MSVC editions earlier than Visual Studio 2011, apparently. This works by copying files into the contrib directory, and making provision to clean them up, which should work on all editions.
2013-02-25Add -d option to pg_basebackup and pg_receivexlog, for connection string.Heikki Linnakangas
Without this, there's no way to pass arbitrary libpq connection parameters to these applications. It's a bit strange that the option is called -d/--dbname, when in fact you can *not* pass a database name in it, but it's consistent with other client applications where a connection string is also passed using -d. Original patch by Amit Kapila, heavily modified by me.
2013-02-24Provide MSVC build setup for pg_xlogdump.Andrew Dunstan
2013-02-23Correct tense in log messagePeter Eisentraut
2013-02-22Add quotes to messagesPeter Eisentraut
2013-02-22Add pg_xlogdump contrib programAlvaro Herrera
This program relies on rm_desc backend routines and the xlogreader infrastructure to emit human-readable rendering of WAL records. Author: Andres Freund, with many reworks by Álvaro Reviewed (in a much earlier version) by Peter Eisentraut
2013-02-22Blind attempt at fixing the non-MSVC Windows buildsAlvaro Herrera
Apparently, they need -DBUILDING_DLL for the Assert() declarations to work correctly.
2013-02-22Fix thinko in previous commit.Heikki Linnakangas
We must still initialize minRecoveryPoint if we start straight with archive recovery, e.g when recovering from a normal base backup taken with pg_start/stop_backup. Otherwise we never consider the system consistent.
2013-02-22If recovery.conf is created after "pg_ctl stop -m i", do crash recovery.Heikki Linnakangas
If you create a base backup using an atomic filesystem snapshot, and try to perform PITR starting from that base backup, or if you just kill a master server and create recovery.conf to put it into standby mode, we don't know how far we need to recover before reaching consistency. Normally in crash recovery, we replay all the WAL present in pg_xlog, and assume that we're consistent after that. And normally in archive recovery, minRecoveryPoint, backupEndRequired, or backupEndPoint is set in the control file, indicating how far we need to replay to reach consistency. But if the server was previously up and running normally, and you kill -9 it or take an atomic filesystem snapshot, none of those fields are set in the control file. The solution is to perform crash recovery first, replaying all the WAL in pg_xlog. After that's done, we assume that the system is consistent like in normal crash recovery, and switch to archive recovery mode after that. Per report from Kyotaro HORIGUCHI. In his scenario, recovery.conf was created after "pg_ctl stop -m i". I'm not sure we need to support that exact scenario, but we should support backing up using a filesystem snapshot, which looks identical. This issue goes back to at least 9.0, where hot standby was introduced and we started to track when consistency is reached. In 9.1 and 9.2, we would open up for hot standby too early, and queries could briefly see an inconsistent state. But 9.2 made it more visible, as we started to PANIC if we see a reference to a non-existing page during recovery, if we've already reached consistency. This is a fairly big patch, so back-patch to 9.2 only, where the issue is more visible. We can consider back-patching further after this has received some more testing in 9.2 and master.
2013-02-21Move relpath() to libpgcommonAlvaro Herrera
This enables non-backend code, such as pg_xlogdump, to use it easily. The previous location, in src/backend/catalog/catalog.c, made that essentially impossible because that file depends on many backend-only facilities; so this needs to live separately.
2013-02-21Remove useless variableAlvaro Herrera
Per Jeff Janes
2013-02-21Need to decorate XactIsoLevel as PGDLLIMPORT for postgres_fdw.Tom Lane
Per buildfarm.
2013-02-21Teach MSVC build system about postgres_fdw.Tom Lane
Per buildfarm.
2013-02-21Add postgres_fdw contrib module.Tom Lane
There's still a lot of room for improvement, but it basically works, and we need this to be present before we can do anything much with the writable-foreign-tables patch. So let's commit it and get on with testing. Shigeru Hanada, reviewed by KaiGai Kohei and Tom Lane
2013-02-20Fix pg_dumpall with database names containing =Heikki Linnakangas
If a database name contained a '=' character, pg_dumpall failed. The problem was in the way pg_dumpall passes the database name to pg_dump on the command line. If it contained a '=' character, pg_dump would interpret it as a libpq connection string instead of a plain database name. To fix, pass the database name to pg_dump as a connection string, "dbname=foo", with the database name escaped if necessary. Back-patch to all supported branches.
2013-02-20Don't pass NULL to fprintf, if a bogus connection string is given to pg_dump.Heikki Linnakangas
Back-patch to all supported branches.
2013-02-20Fix yet another typo in comment.Heikki Linnakangas
Etsuro Fujita
2013-02-18Move ExceptionalCondition back to postgres.hAlvaro Herrera
It needs to be defined in the backend even when assertions are not enabled. It's cleaner to put it back, than create a separate #ifdef section in c.h. Per trouble report from Jeff Janes
2013-02-18Split pgstat file in smaller piecesAlvaro Herrera
We now write one file per database and one global file, instead of having the whole thing in a single huge file. This reduces the I/O that must be done when partial data is required -- which is all the time, because each process only needs information on its own database anyway. Also, the autovacuum launcher does not need data about tables and functions in each database; having the global stats for all DBs is enough. Catalog version bumped because we have a new subdir under PGDATA. Author: Tomas Vondra. Some rework by Álvaro Testing by Jeff Janes Other discussion by Heikki Linnakangas, Tom Lane.
2013-02-17Add ALTER ROLE ALL SET commandPeter Eisentraut
This generalizes the existing ALTER ROLE ... SET and ALTER DATABASE ... SET functionality to allow creating settings that apply to all users in all databases. reviewed by Pavel Stehule
2013-02-16Warn about initdb using mount-pointsBruce Momjian
Add code to detect and warn about trying to initdb or create pg_xlog on mount points.
2013-02-15Better fix for "unarchived WAL files get deleted on crash recovery" bug.Heikki Linnakangas
Revert my earlier fix for the bug that unarchived WAL files get deleted on crash recovery, commit c9cc7e05c6d82a9781883a016c70d95aa4923122. We create a .done file for files streamed or restored from archive, so the WAL file recycling logic used during normal operation works just as well during archive recovery. Per Fujii Masao's suggestion.
2013-02-15Force archive_status of .done for xlogs created by dearchival/replication.Simon Riggs
This is a forward-patch of commit 6f4b8a4f4f7a2d683ff79ab59d3693714b965e3d, applied to 9.2 back in August. The plan was to do something else in master, but it looks like it's not going to happen, so let's just apply the 9.2 solution to master as well. Fujii Masao
2013-02-15Don't delete unarchived WAL files during crash recovery.Heikki Linnakangas
Bug reported by Jehan-Guillaume (ioguix) de Rorthais. This was introduced with the change to keep WAL files restored from archive in pg_xlog, in 9.2.
2013-02-14pgindent: Fix order in instructionsPeter Eisentraut
The previous order of steps didn't literally work, because git clean -fdx would delete the downloaded typedefs.list. Also, pgindent needs to be called with a path when one is in at the top of the build tree.
2013-02-14Invent pre-commit/pre-prepare/pre-subcommit events for xact callbacks.Tom Lane
Currently it's only possible for loadable modules to get control during post-commit cleanup of a transaction. That doesn't work too well if they want to do something that could throw an error; for example, an FDW might need to issue a remote commit, which could well fail. To improve matters, extend the existing APIs for XactCallback and SubXactCallback functions to provide new pre-commit events for this purpose. The release notes will need to mention that existing callback functions should be checked to make sure they don't do something unwanted when one of the new event types occurs. In the examples within our source tree, contrib/sepgsql was fine but plpgsql had been a bit too cute.
2013-02-13Fix CVE-2013-0255 properly.Tom Lane
Revert commit ab0f7b6089fd215f6ce6081e2e222c38d643a526 (in HEAD only) in favor of the proper solution, which is to declare enum_recv() correctly in the system catalogs. It should be declared to take type "internal" not "cstring". Also improve the type_sanity regression test, which should have caught this typo, so that it actually would. Most of the relevant checks on the signature of type I/O functions should not have been restricted to basetypes/pseudotypes, as they should apply to any type's I/O functions.
2013-02-13Fix bogus when-to-deregister-from-listener-array logic.Tom Lane
Since a backend adds itself to the global listener array during Exec_ListenPreCommit, it's inappropriate for it to remove itself during Exec_UnlistenCommit or Exec_UnlistenAllCommit --- that leads to failure when committing a transaction that did UNLISTEN then LISTEN, since we end up not registered though we should be. (This leads to missing later notifications, or to Assert failures in assert-enabled builds.) Instead deal with deregistering at the bottom of AtCommit_Notify, when we know the final state of the listenChannels list. Also, simplify the representation of registration status by replacing the transient backendHasExecutedInitialListen flag with an amRegisteredListener flag. Per report from Greg Sabino Mullane. Back-patch to 9.0, where the problem was introduced during the LISTEN/NOTIFY rewrite.
2013-02-13Update visibility map in the second phase of vacuum.Heikki Linnakangas
There's a high chance that a page becomes all-visible when the second phase of vacuum removes all the dead tuples on it, so it makes sense to check for that. Otherwise the visibility map won't get updated until the next vacuum. Pavan Deolasee, reviewed by Jeff Janes.
2013-02-12Rename "string" pstrdup argument to "in"Alvaro Herrera
The former name collides with a symbol also used in the isolation test's parser, causing assorted failures in certain platforms.
2013-02-12Don't build libpgcommon_srv.a just yetAlvaro Herrera
It's empty, and some archivers do not support that case.
2013-02-12Create libpgcommon, and move pg_malloc et al to itAlvaro Herrera
libpgcommon is a new static library to allow sharing code among the various frontend programs and backend; this lets us eliminate duplicate implementations of common routines. We avoid libpgport, because that's intended as a place for porting issues; per discussion, it seems better to keep them separate. The first use case, and the only implemented by this patch, is pg_malloc and friends, which many frontend programs were already using. At the same time, we can use this to provide palloc emulation functions for the frontend; this way, some palloc-using files in the backend can also be used by the frontend cleanly. To do this, we change palloc() in the backend to be a function instead of a macro on top of MemoryContextAlloc(). This was previously believed to cause loss of performance, but this implementation has been tweaked by Tom and Andres so that on modern compilers it provides a slight improvement over the previous one. This lets us clean up some places that were already with localized hacks. Most of the pg_malloc/palloc changes in this patch were authored by Andres Freund. Zoltán Böszörményi also independently provided a form of that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12Add noreturn attributes to some error reporting functionsPeter Eisentraut
2013-02-11Support unlogged GiST index.Heikki Linnakangas
The reason this wasn't supported before was that GiST indexes need an increasing sequence to detect concurrent page-splits. In a regular WAL- logged GiST index, the LSN of the page-split record is used for that purpose, and in a temporary index, we can get away with a backend-local counter. Neither of those methods works for an unlogged relation. To provide such an increasing sequence of numbers, create a "fake LSN" counter that is saved and restored across shutdowns. On recovery, unlogged relations are blown away, so the counter doesn't need to survive that either. Jeevan Chalke, based on discussions with Robert Haas, Tom Lane and me.
2013-02-11Fix checkpoint after fast promotion.Heikki Linnakangas
The intention was to request a regular online checkpoint immediately after end of recovery, when performing "fast promotion". However, because the checkpoint was requested before other backends were allowed to write WAL, the checkpointer process performed a restartpoint rather than a checkpoint. Delay the RequestCheckPoint call until after recovery has truly ended, so that you get a real checkpoint.
2013-02-11Include previous TLI in end-of-recovery and shutdown checkpoint records.Heikki Linnakangas
This isn't used for anything but a sanity check at the moment, but it could be highly valuable for debugging purposes. It could also be used to recreate timeline history by traversing WAL, which seems useful.
2013-02-10Further cleanup of gistsplit.c.Tom Lane
After further reflection I was unconvinced that the existing coding is guaranteed to return valid union datums in every code path for multi-column indexes. Fix that by forcing a gistunionsubkey() call at the end of the recursion. Having done that, we can remove some clearly-redundant calls elsewhere. This should be a little faster for multi-column indexes (since the previous coding would uselessly do such a call for each column while unwinding the recursion), as well as much harder to break. Also, simplify the handling of cases where one side or the other of a primary split contains only don't-care tuples. The previous coding used a very ugly hack in removeDontCares() that essentially forced one random tuple to be treated as non-don't-care, providing a random initial choice of seed datum for the secondary split. It seems unlikely that that method will give better-than-random splits. Instead, treat such a split as degenerate and just let the next column determine the split, the same way that we handle fully degenerate cases where the two sides produce identical union datums.