summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2012-08-29Optimize SP-GiST insertions.Heikki Linnakangas
This includes two micro-optimizations to the tight inner loop in descending the SP-GiST tree: 1. avoid an extra function call to index_getprocinfo when calling user-defined choose function, and 2. avoid a useless palloc+pfree when node labels are not used.
2012-08-28Add strerror() string to chdir() error messagePeter Eisentraut
2012-08-28Split heapam_xlog.h from heapam.hAlvaro Herrera
The heapam XLog functions are used by other modules, not all of which are interested in the rest of the heapam API. With this, we let them get just the XLog stuff in which they are interested and not pollute them with unrelated includes. Also, since heapam.h no longer requires xlog.h, many files that do include heapam.h no longer get xlog.h automatically, including a few headers. This is useful because heapam.h is getting pulled in by execnodes.h, which is in turn included by a lot of files.
2012-08-28remove catcache.h from syscache.hAlvaro Herrera
Instead, place a forward struct declaration for struct catclist in syscache.h. This reduces header proliferation somewhat.
2012-08-28Split resowner.hAlvaro Herrera
This lets files that are mere users of ResourceOwner not automatically include the headers for stuff that is managed by the resowner mechanism.
2012-08-28add #includes to plpy_subxactobject.h to make it compile standaloneAlvaro Herrera
2012-08-28Prevent psql tab completion in SET from adding TO when the equals signBruce Momjian
has no space before it. Report by Erik Rijkers
2012-08-28syncrep.h must include xlogdefs.hAlvaro Herrera
2012-08-28Small punctuation fixesPeter Eisentraut
2012-08-27Fix DROP INDEX CONCURRENTLY IF EXISTS.Tom Lane
This threw ERROR, not the expected NOTICE, if the index didn't exist. The bug was actually visible in not-as-expected regression test output, so somebody wasn't paying too close attention in commit 8cb53654dbdb4c386369eb988062d0bbb6de725e. Per report from Brendan Byrd.
2012-08-27Have pgindent requre pg_bsd_indent version 1.2 now that a new versionBruce Momjian
has been created by adding #include <stdlib.h> to parse.c. per request from Kevin Grittner.
2012-08-27Collect and use histograms of lower and upper bounds for range types.Heikki Linnakangas
This enables selectivity estimation of the <<, >>, &<, &> and && operators, as well as the normal inequality operators: <, <=, >=, >. "range @> element" is also supported, but the range-variant @> and <@ operators are not, because they cannot be sensibly estimated with lower and upper bound histograms alone. We would need to make some assumption about the lengths of the ranges for that. Alexander's patch included a separate histogram of lengths for that, but I left that out of the patch for simplicity. Hopefully that will be added as a followup patch. The fraction of empty ranges is also calculated and used in estimation. Alexander Korotkov, heavily modified by me.
2012-08-27pg_basebackup: Correct error messagePeter Eisentraut
It still thought that the --xlog-method option argument could be empty, as in a previous version of this feature.
2012-08-26Fix up planner infrastructure to support LATERAL properly.Tom Lane
This patch takes care of a number of problems having to do with failure to choose valid join orders and incorrect handling of lateral references pulled up from subqueries. Notable changes: * Add a LateralJoinInfo data structure similar to SpecialJoinInfo, to represent join ordering constraints created by lateral references. (I first considered extending the SpecialJoinInfo structure, but the semantics are different enough that a separate data structure seems better.) Extend join_is_legal() and related functions to prevent trying to form unworkable joins, and to ensure that we will consider joins that satisfy lateral references even if the joins would be clauseless. * Fill in the infrastructure needed for the last few types of relation scan paths to support parameterization. We'd have wanted this eventually anyway, but it is necessary now because a relation that gets pulled up out of a UNION ALL subquery may acquire a reltargetlist containing lateral references, meaning that its paths *have* to be parameterized whether or not we have any code that can push join quals down into the scan. * Compute data about lateral references early in query_planner(), and save in RelOptInfo nodes, to avoid repetitive calculations later. * Assorted corner-case bug fixes. There's probably still some bugs left, but this is a lot closer to being real than it was before.
2012-08-25Use psql_error() for most psql error calls, per request from Magnus.Bruce Momjian
2012-08-25Allow text timezone designations, e.g. "America/Chicago", when using theBruce Momjian
ISO "T" timestamptz format.
2012-08-24Fix issues with checks for unsupported transaction states in Hot Standby.Tom Lane
The GUC check hooks for transaction_read_only and transaction_isolation tried to check RecoveryInProgress(), so as to disallow setting read/write mode or serializable isolation level (respectively) in hot standby sessions. However, GUC check hooks can be called in many situations where we're not connected to shared memory at all, resulting in a crash in RecoveryInProgress(). Among other cases, this results in EXEC_BACKEND builds crashing during child process start if default_transaction_isolation is serializable, as reported by Heikki Linnakangas. Protect those calls by silently allowing any setting when not inside a transaction; which is okay anyway since these GUCs are always reset at start of transaction. Also, add a check to GetSerializableTransactionSnapshot() to complain if we are in hot standby. We need that check despite the one in check_XactIsoLevel() because default_transaction_isolation could be serializable. We don't want to complain any sooner than this in such cases, since that would prevent running transactions at all in such a state; but a transaction can be run, if SET TRANSACTION ISOLATION is done before setting a snapshot. Per report some months ago from Robert Haas. Back-patch to 9.1, since these problems were introduced by the SSI patch. Kevin Grittner and Tom Lane, with ideas from Heikki Linnakangas
2012-08-24Put options on man page and in help output in slightly better orderPeter Eisentraut
2012-08-23libpq: Fix memory leak in URI parserPeter Eisentraut
When an invalid query parameter is reported, some memory leaks. found by Coverity
2012-08-23Fix cascading privilege revoke to notice when privileges are still held.Tom Lane
If we revoke a grant option from some role X, but X still holds the option via another grant, we should not recursively revoke the privilege from role(s) Y that X had granted it to. This was supposedly fixed as one aspect of commit 4b2dafcc0b1a579ef5daaa2728223006d1ff98e9, but I must not have tested it, because in fact that code never worked: it forgot to shift the grant-option bits back over when masking the bits being revoked. Per bug #6728 from Daniel German. Back-patch to all active branches, since this has been wrong since 8.0.
2012-08-21Mark DateTimeParseError() noreturnPeter Eisentraut
This avoids a warning from clang 3.2 about an uninitialized variable 'dtype' in date_in().
2012-08-21Avoid somewhat-theoretical overflow risks in RecordIsValid().Tom Lane
This improves on commit 51fed14d73ed3acd2282b531fb1396877e44e86a by eliminating the assumption that we can form <some pointer value> + <some offset> without overflow. The entire point of those tests is that we don't trust the offset value, so coding them in a way that could wrap around if the buffer happens to be near the top of memory doesn't seem sound. Instead, track the remaining space as a size_t variable and compare offsets against that. Also, improve comment about why we need the extra early check on xl_tot_len.
2012-08-21Fix dumping of security_barrier views with circular dependencies.Tom Lane
If a view has circular dependencies, pg_dump splits it into a CREATE TABLE and a CREATE RULE command to break the dependency loop. However, if the view has reloptions, those options cannot be applied in the CREATE TABLE command, because views and tables have different allowed reloptions so CREATE TABLE would reject them. Instead apply the reloptions after the CREATE RULE, using ALTER VIEW SET.
2012-08-21Improve C comments in GetSnapshotData.Robert Haas
Move discussion of why our algorithm for taking snapshots in recovery to a more appropriate location in the function, and delete incorrect mention of taking a lock.
2012-08-21Teach compiler that ereport(>=ERROR) does not returnPeter Eisentraut
When elevel >= ERROR, we add an abort() call to the ereport() macro to give the compiler a hint that the ereport() expansion will not return, but the abort() isn't actually reached because the longjmp happens in errfinish(). Because the effect of ereport() varies with the elevel, we cannot use standard compiler attributes such as noreturn for this.
2012-08-20Remove external PID file on postmaster exitPeter Eisentraut
2012-08-20Improved tab completion for CLUSTER VERBOSE.Robert Haas
Jeff Janes
2012-08-20Tab complete "TABLE whatever DROP CONSTRAINT" with a constraint name.Robert Haas
Jeff Janes
2012-08-20Don't get confused if a WAL partial record header has xl_tot_len == 0.Heikki Linnakangas
If a WAL record header was split across pages, but xl_tot_len was 0, we would get confused and conclude that we had already read the whole record, and proceed to CRC check it. That can lead to a crash in RecordIsValid(), which isn't careful to not read beyond end-of-record, as defined by xl_tot_len. Add an explicit sanity check for xl_tot_len <= SizeOfXlogRecord. Also, make RecordIsValid() more robust by checking in each step that it doesn't try to access memory beyond end of record, even if a length field in the record's or a backup block's header is bogus. Per report and analysis by Tom Lane.
2012-08-19Fix typo in comment.Tom Lane
2012-08-19Remove obsolete comment.Tom Lane
2012-08-19Allow OLD and NEW in multi-row VALUES within rules.Tom Lane
Now that we have LATERAL, it's fairly painless to allow this case, which was left as a TODO in the original multi-row VALUES implementation.
2012-08-18Make use of LATERAL in information_schema.sequences view.Tom Lane
It said "XXX: The following could be improved if we had LATERAL" ... so let's do that. No catversion bump since either version of the view works fine.
2012-08-18Another round of planner fixes for LATERAL.Tom Lane
Formerly, subquery pullup had no need to examine other entries in the range table, since they could not contain any references to the subquery being pulled up. That's no longer true with LATERAL, so now we need to be able to visit rangetable subexpressions to replace Vars referencing the pulled-up subquery. Also, this means that extract_lateral_references must be unsurprised at encountering lateral PlaceHolderVars, since such might be created when pulling up a subquery that's underneath an outer join with respect to the lateral reference.
2012-08-17Check LIBXML_VERSION instead of testing in configure script.Tom Lane
We had put a test for libxml2's xmlStructuredErrorContext variable in configure, but of course that doesn't work on Windows builds. The next best alternative seems to be to test the LIBXML_VERSION symbol provided by xmlversion.h. Per report from Talha Bin Rizwan, though this fixes it in a different way than his proposed patch.
2012-08-16Delete inaccurate C comment about FSM and adding pages, per Robert Haas.Bruce Momjian
2012-08-16Add URL for include file visualization tool.Bruce Momjian
2012-08-16Allow create_index_paths() to consider multiple join bitmapscan paths.Tom Lane
In the initial cut at the "parameterized paths" feature, I'd simplified create_index_paths() to the point where it would only generate a single parameterized bitmap path per relation. Experimentation with an example supplied by Josh Berkus convinces me that that's not good enough: we really need to consider a bitmap path for each possible outer relation. Otherwise we have regressions relative to pre-9.2 versions, in which the planner picks a plain indexscan where it should have used a bitmap scan in queries involving three or more tables. Indeed, after fixing this, several queries in the regression tests show improved plans as a result of using bitmap not plain indexscans.
2012-08-16Suppress possibly-uninitialized-variable warning.Tom Lane
2012-08-16Add possible alternate tool for pgrminclude, from Peter GeogheganBruce Momjian
2012-08-16Add SP-GiST support for range types.Heikki Linnakangas
The implementation is a quad-tree, largely copied from the quad-tree implementation for points. The lower and upper bound of ranges are the 2d coordinates, with some extra code to handle empty ranges. I left out the support for adjacent operator, -|-, from the original patch. Not because there was necessarily anything wrong with it, but it was more complicated than the other operators, and I only have limited time for reviewing. That will follow as a separate patch. Alexander Korotkov, reviewed by Jeff Davis and me.
2012-08-16Fix GiST buffering build bug, which caused "failed to re-find parent" errors.Heikki Linnakangas
We use a hash table to track the parents of inner pages, but when inserting to a leaf page, the caller of gistbufferinginserttuples() must pass a correct block number of the leaf's parent page. Before gistProcessItup() descends to a child page, it checks if the downlink needs to be adjusted to accommodate the new tuple, and updates the downlink if necessary. However, updating the downlink might require splitting the page, which might move the downlink to a page to the right. gistProcessItup() doesn't realize that, so when it descends to the leaf page, it might pass an out-of-date parent block number as a result. Fix that by returning the block a tuple was inserted to from gistbufferinginserttuples(). This fixes the bug reported by Zdeněk Jílovec.
2012-08-15Add C comment about new \c parameter requirement for crashed connections.Bruce Momjian
2012-08-15Update C comment to NOTICE to reflect previous commit changing the errorBruce Momjian
level, per report from Tom.
2012-08-15In psql, if the is no connection object, e.g. due to a server crash,Bruce Momjian
require all parameters for \c, rather than using the defaults, which might be wrong.
2012-08-15Fix rescan logic in nodeCtescan.Tom Lane
The previous coding essentially assumed that nodes would be rescanned in the same order they were initialized in; or at least that the "leader" of a group of CTEscans would be rescanned before any others were required to execute. Unfortunately, that isn't even a little bit true. It's possible to devise queries in which the leader isn't rescanned until other CTEscans on the same CTE have run to completion, or even in which the leader never gets a rescan call at all. The fix makes the leader specially responsible only for initial creation and final destruction of the tuplestore; rescan resets are now a symmetrically shared responsibility. This means that we might reset the tuplestore multiple times when restarting a plan subtree containing multiple CTEscans; but resetting an already-empty tuplestore is cheap enough that that doesn't seem like a problem. Per report from Adam Mackler; the new regression test cases are based on his example query. Back-patch to 8.4 where CTE scans were introduced.
2012-08-15On second thought, explain why date_trunc("week") on interval values isBruce Momjian
not supported in the error message, rather than the docs.
2012-08-15Add C comment that '=' is not documented for plpgsql assignment.Bruce Momjian
2012-08-15Disallow extensions from owning the schema they are assigned to.Tom Lane
This situation creates a dependency loop that confuses pg_dump and probably other things. Moreover, since the mental model is that the extension "contains" schemas it owns, but "is contained in" its extschema (even though neither is strictly true), having both true at once is confusing for people too. So prevent the situation from being set up. Reported and patched by Thom Brown. Back-patch to 9.1 where extensions were added.
2012-08-15Properly escape usernames in initdb, so names with single-quotes areBruce Momjian
supported. Also add assert to catch future breakage. Also, improve documentation that "double"-quotes must be used in pg_hba.conf (not single quotes).