aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
...
* Attempt to unbreak pg_test_timing on Windows.Robert Haas2012-03-28
| | | | Per buildfarm, and Álvaro Herrera.
* pg_basebackup: Error handling fixes.Robert Haas2012-03-28
| | | | Thomas Ogrisegg and Fujii Masao
* pg_basebackup: Error message improvements.Robert Haas2012-03-28
| | | | Fujii Masao
* Bend parse location rules for the convenience of pg_stat_statements.Tom Lane2012-03-27
| | | | | | | | | | | | | | | | Generally, the parse location assigned to a multiple-token construct is the location of its leftmost token. This commit breaks that rule for the syntaxes TYPENAME 'LITERAL' and CAST(CONSTANT AS TYPENAME) --- the resulting Const will have the location of the literal string, not the typename or CAST keyword. The cases where this matters are pretty thin on the ground (no error messages in the regression tests change, for example), and it's unlikely that any user would be confused anyway by an error cursor pointing at the literal. But still it's less than consistent. The reason for changing it is that contrib/pg_stat_statements wants to know the parse location of the original literal, and it was agreed that this is the least unpleasant way to preserve that information through parse analysis. Peter Geoghegan
* Add some infrastructure for contrib/pg_stat_statements.Tom Lane2012-03-27
| | | | | | | | | | | | | | | | | | | | Add a queryId field to Query and PlannedStmt. This is not used by the core backend, except for being copied around at appropriate times. It's meant to allow plug-ins to track a particular query forward from parse analysis to execution. The queryId is intentionally not dumped into stored rules (and hence this commit doesn't bump catversion). You could argue that choice either way, but it seems better that stored rule strings not have any dependency on plug-ins that might or might not be present. Also, add a post_parse_analyze_hook that gets invoked at the end of parse analysis (but only for top-level analysis of complete queries, not cases such as analyzing a domain's default-value expression). This is mainly meant to be used to compute and assign a queryId, but it could have other applications. Peter Geoghegan
* New GUC, track_iotiming, to track I/O timings.Robert Haas2012-03-27
| | | | | | | | Currently, the only way to see the numbers this gathers is via EXPLAIN (ANALYZE, BUFFERS), but the plan is to add visibility through the stats collector and pg_stat_statements in subsequent patches. Ants Aasma, reviewed by Greg Smith, with some further changes by me.
* pg_dump: Small message adjustment for consistencyPeter Eisentraut2012-03-27
|
* Remove dead assignmentPeter Eisentraut2012-03-26
| | | | found by Coverity
* Code cleanup for heap_freeze_tuple.Robert Haas2012-03-26
| | | | | | | It used to be case that lazy vacuum could call this function with only a shared lock on the buffer, but neither lazy vacuum nor any other code path does that any more. Simplify the code accordingly and clean up some related, obsolete comments.
* Fix COPY FROM for null marker strings that correspond to invalid encoding.Tom Lane2012-03-25
| | | | | | | | | | | | | The COPY documentation says "COPY FROM matches the input against the null string before removing backslashes". It is therefore reasonable to presume that null markers like E'\\0' will work ... and they did, until someone put the tests in the wrong order during microoptimization-driven rewrites. Since then, we've been failing if the null marker is something that would de-escape to an invalidly-encoded string. Since null markers generally need to be something that can't appear in the data, this represents a nontrivial loss of functionality; surprising nobody noticed it earlier. Per report from Jeff Davis. Backpatch to 8.4 where this got broken.
* Replace empty locale name with implied value in CREATE DATABASE and initdb.Tom Lane2012-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | setlocale() accepts locale name "" as meaning "the locale specified by the process's environment variables". Historically we've accepted that for Postgres' locale settings, too. However, it's fairly unsafe to store an empty string in a new database's pg_database.datcollate or datctype fields, because then the interpretation could vary across postmaster restarts, possibly resulting in index corruption and other unpleasantness. Instead, we should expand "" to whatever it means at the moment of calling CREATE DATABASE, which we can do by saving the value returned by setlocale(). For consistency, make initdb set up the initial lc_xxx parameter values the same way. initdb was already doing the right thing for empty locale names, but it did not replace non-empty names with setlocale results. On a platform where setlocale chooses to canonicalize the spellings of locale names, this would result in annoying inconsistency. (It seems that popular implementations of setlocale don't do such canonicalization, which is a pity, but the POSIX spec certainly allows it to be done.) The same risk of inconsistency leads me to not venture back-patching this, although it could certainly be seen as a longstanding bug. Per report from Jeff Davis, though this is not his proposed patch.
* Fix planner's handling of outer PlaceHolderVars within subqueries.Tom Lane2012-03-24
| | | | | | | | | | | | | | | | | | | | | | | For some reason, in the original coding of the PlaceHolderVar mechanism I had supposed that PlaceHolderVars couldn't propagate into subqueries. That is of course entirely possible. When it happens, we need to treat an outer-level PlaceHolderVar much like an outer Var or Aggref, that is SS_replace_correlation_vars() needs to replace the PlaceHolderVar with a Param, and then when building the finished SubPlan we have to provide the PlaceHolderVar expression as an actual parameter for the SubPlan. The handling of the contained expression is a bit delicate but it can be treated exactly like an Aggref's expression. In addition to the missing logic in subselect.c, prepjointree.c was failing to search subqueries for PlaceHolderVars that need their relids adjusted during subquery pullup. It looks like everyplace else that touches PlaceHolderVars got it right, though. Per report from Mark Murawski. In 9.1 and HEAD, queries affected by this oversight would fail with "ERROR: Upper-level PlaceHolderVar found where not expected". But in 9.0 and 8.4, you'd silently get possibly-wrong answers, since the value transmitted into the subquery wouldn't go to null when it should.
* Cast some printf arguments to avoid possibly-nonportable behavior.Tom Lane2012-03-23
| | | | Per compiler warnings on buildfarm member black_firefly.
* Refactor simplify_function et al to centralize argument simplification.Tom Lane2012-03-23
| | | | | | | | | | We were doing the recursive simplification of function/operator arguments in half a dozen different places, with rather baroque logic to ensure it didn't get done multiple times on some arguments. This patch improves that by postponing argument simplification until after we've dealt with named parameters and added any needed default expressions. Marti Raudsepp, somewhat hacked on by me
* Code review for protransform patches.Tom Lane2012-03-23
| | | | | | | | | | | | | | | | | Fix loss of previous expression-simplification work when a transform function fires: we must not simply revert to untransformed input tree. Instead build a dummy FuncExpr node to pass to the transform function. This has the additional advantage of providing a simpler, more uniform API for transform functions. Move documentation to a somewhat less buried spot, relocate some poorly-placed code, be more wary of null constants and invalid typmod values, add an opr_sanity check on protransform function signatures, and some other minor cosmetic adjustments. Note: although this patch touches pg_proc.h, no need for catversion bump, because the changes are cosmetic and don't actually change the intended catalog contents.
* Fix GET DIAGNOSTICS for case of assignment to function's first variable.Tom Lane2012-03-22
| | | | | | | | | | | An incorrect and entirely unnecessary "safety check" in exec_stmt_getdiag() caused the code to treat an assignment to a variable with dno zero as a no-op. Unfortunately, that's a perfectly valid dno. This has been broken since GET DIAGNOSTICS was invented. It's not terribly surprising that the bug went unnoticed for so long, since in most cases you probably wouldn't use the function's first-created variable (normally its first parameter) as a GET DIAGNOSTICS target. Nonetheless, it's broken. Per bug #6551 from Adam Buraczewski.
* Refactor to eliminate duplicate copies of conninfo default-finding code.Tom Lane2012-03-22
| | | | Alex Shulgin, lightly edited by me
* If a role has a password expiration date, show that in psql's \du output.Tom Lane2012-03-22
| | | | | | | | | Per a suggestion from Euler Taveira, it seems like a good idea to include this information in \du (and \dg) output. This costs nothing for people who are not using the VALID UNTIL feature, while for those who are, it's rather critical information. Fabrízio de Royes Mello
* Clean up compiler warnings from unused variables with asserts disabledPeter Eisentraut2012-03-21
| | | | | | For those variables only used when asserts are enabled, use a new macro PG_USED_FOR_ASSERTS_ONLY, which expands to __attribute__((unused)) when asserts are not enabled.
* Add installing entab to pgindent instructionsPeter Eisentraut2012-03-21
| | | | And minor other pgindent documentation tweaks.
* Allow new relmapper entries when allow_system_table_mods is true.Tom Lane2012-03-21
| | | | | | | | | | This restores the pre-9.0 situation that it's possible to add new indexes on pg_class and other mapped-but-not-shared catalogs, so long as you broke the glass and flipped the big red Dont-Touch-Me switch. As before, there are a lot of gotchas, and you'd have to be pretty desperate to try this on a production database; but there doesn't seem to be a reason for relmapper.c to be preventing such things all by itself. Per experimentation with a case suggested by Cody Cutrer.
* Improve connectMaintenanceDatabase() error reporting.Robert Haas2012-03-21
| | | | | | | | The prior coding instructs the user to pick an alternative maintenance database, but this is overly clever, since it obscures whatever the real cause of the failure is. Josh Kupershmidt
* Add some CHECK_FOR_INTERRUPTS() calls to the heap-sort call path.Robert Haas2012-03-20
| | | | | | | I broke this in commit 337b6f5ecf05b21b5e997986884d097d60e4e3d0, which among other things arranged for quicksorts to CHECK_FOR_INTERRUPTS() slightly less frequently. Sadly, it also arranged for heapsorts to CHECK_FOR_INTERRUPTS() much less frequently. Repair.
* pg_dump: get rid of die_horriblyAlvaro Herrera2012-03-20
| | | | | | | | | | | | | | | | | | The old code was using exit_horribly or die_horribly other depending on whether it had an ArchiveHandle on which to close the connection or not; but there were places that were passing a NULL ArchiveHandle to die_horribly, and other places that used exit_horribly while having an AH available. So there wasn't all that much consistency. Improve the situation by keeping only one of the routines, and instead of having to pass the AH down from the caller, arrange for it to be present for an on_exit_nicely callback to operate on. Author: Joachim Wieland Some tweaks by me Per a suggestion from Robert Haas, in the ongoing "parallel pg_dump" saga.
* pg_dump: Remove undocumented "files" output formatPeter Eisentraut2012-03-20
| | | | | | | This was for demonstration only, and now it was creating compiler warnings from zlib without an obvious fix (see also d923125b77c5d698bb8107a533a21627582baa43), let's just remove it. The "directory" format is presumably similar enough anyway.
* Restructure SELECT INTO's parsetree representation into CreateTableAsStmt.Tom Lane2012-03-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | Making this operation look like a utility statement seems generally a good idea, and particularly so in light of the desire to provide command triggers for utility statements. The original choice of representing it as SELECT with an IntoClause appendage had metastasized into rather a lot of places, unfortunately, so that this patch is a great deal more complicated than one might at first expect. In particular, keeping EXPLAIN working for SELECT INTO and CREATE TABLE AS subcommands required restructuring some EXPLAIN-related APIs. Add-on code that calls ExplainOnePlan or ExplainOneUtility, or uses ExplainOneQuery_hook, will need adjustment. Also, the cases PREPARE ... SELECT INTO and CREATE RULE ... SELECT INTO, which formerly were accepted though undocumented, are no longer accepted. The PREPARE case can be replaced with use of CREATE TABLE AS EXECUTE. The CREATE RULE case doesn't seem to have much real-world use (since the rule would work only once before failing with "table already exists"), so we'll not bother with that one. Both SELECT INTO and CREATE TABLE AS still return a command tag of "SELECT nnnn". There was some discussion of returning "CREATE TABLE nnnn", but for the moment backwards compatibility wins the day. Andres Freund and Tom Lane
* pg_dump: fix double free of query resultsAlvaro Herrera2012-03-19
| | | | | | | This bug was introduced while refactoring in commit 1631598e --- no need to back-patch. Bug report and fix from Joachim Wieland.
* plperl: Package-qualify _TDAlvaro Herrera2012-03-19
| | | | | | | | | | Failing to do so causes trigger invocation to fail when they are nested within a function invocation that changes the current package. Backpatch to 9.1; previous releases used a different method to obtain _TD. Per bug report from Mark Murawski (bug #6511) Author: Alex Hunsaker
* Honor inputdir and outputdir when converting regression files.Andrew Dunstan2012-03-17
| | | | | | | | | When converting source files, pg_regress' inputdir and outputdir options were ignored when computing the locations of the destination files. In consequence, these options were effectively unusable when the regression inputs need to be adjusted by pg_regress. This patch makes pg_regress put the converted files in the same place that these options specify non-converted input or results files are to be found. Backpatched to all live branches.
* libpq: Fix minor memory leaksPeter Eisentraut2012-03-16
| | | | | | | | When using connection info arrays with a conninfo string in the dbname slot, some memory would be leaked if an error occurred while processing the following array slots. found by Coverity
* psql: Remove inappropriate const qualifiersPeter Eisentraut2012-03-16
| | | | | Since mbvalidate() can alter the string it validates, having the callers claim that the strings they accept are const is inappropriate.
* pg_dump: Fix crash with invalid pg_cast rowPeter Eisentraut2012-03-16
| | | | | | | An invalid combination of pg_cast.castfunc and pg_cast.castmethod would result in a segmentation fault. Now it prints a warning. found by Coverity
* pg_restore: Fix memory and file descriptor leak with directory formatPeter Eisentraut2012-03-16
| | | | found by Coverity
* backend: Fix minor memory leak in configuration file processingPeter Eisentraut2012-03-16
| | | | | | Just for consistency with the other code paths. found by Coverity
* Improve commentary in match_pathkeys_to_index().Tom Lane2012-03-16
| | | | | | | For a little while there I thought match_pathkeys_to_index() was broken because it wasn't trying to match index columns to pathkeys in order. Actually that's correct, because GiST can support ordering operators on any random collection of index columns, but it sure needs a comment.
* Revisit handling of UNION ALL subqueries with non-Var output columns.Tom Lane2012-03-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit 57664ed25e5dea117158a2e663c29e60b3546e1c I tried to fix a bug reported by Teodor Sigaev by making non-simple-Var output columns distinct (by wrapping their expressions with dummy PlaceHolderVar nodes). This did not work too well. Commit b28ffd0fcc583c1811e5295279e7d4366c3cae6c fixed some ensuing problems with matching to child indexes, but per a recent report from Claus Stadler, constraint exclusion of UNION ALL subqueries was still broken, because constant-simplification didn't handle the injected PlaceHolderVars well either. On reflection, the original patch was quite misguided: there is no reason to expect that EquivalenceClass child members will be distinct. So instead of trying to make them so, we should ensure that we can cope with the situation when they're not. Accordingly, this patch reverts the code changes in the above-mentioned commits (though the regression test cases they added stay). Instead, I've added assorted defenses to make sure that duplicate EC child members don't cause any problems. Teodor's original problem ("MergeAppend child's targetlist doesn't match MergeAppend") is addressed more directly by revising prepare_sort_from_pathkeys to let the parent MergeAppend's sort list guide creation of each child's sort list. In passing, get rid of add_sort_column; as far as I can tell, testing for duplicate sort keys at this stage is dead code. Certainly it doesn't trigger often enough to be worth expending cycles on in ordinary queries. And keeping the test would've greatly complicated the new logic in prepare_sort_from_pathkeys, because comparing pathkey list entries against a previous output array requires that we not skip any entries in the list. Back-patch to 9.1, like the previous patches. The only known issue in this area that wasn't caused by the ill-advised previous patches was the MergeAppend planning failure, which of course is not relevant before 9.1. It's possible that we need some of the new defenses against duplicate child EC entries in older branches, but until there's some clear evidence of that I'm going to refrain from back-patching further.
* Add comments explaining why our Itanium spinlock implementation is safe.Heikki Linnakangas2012-03-16
|
* Add const qualifier to tzn returned by timestamp2tm()Peter Eisentraut2012-03-15
| | | | | The tzn value might come from tm->tm_zone, which libc declares as const, so it's prudent that the upper layers know about this as well.
* Remove unused tzn arguments for timestamp2tm()Peter Eisentraut2012-03-15
|
* Improve EncodeDateTime and EncodeTimeOnly APIsPeter Eisentraut2012-03-14
| | | | | Use an explicit argument to tell whether to include the time zone in the output, rather than using some undocumented pointer magic.
* Add missing va_end() callsPeter Eisentraut2012-03-14
| | | | found by Coverity
* COPY: Add an assertionPeter Eisentraut2012-03-14
| | | | | | This is for tools such as Coverity that don't know that the grammar enforces that the case of not having a relation (but instead a query) cannot happen in the FROM case.
* Add additional safety check against invalid backup label filePeter Eisentraut2012-03-14
| | | | | | | It was already checking for invalid data after "BACKUP FROM", but would possibly crash if "BACKUP FROM" was missing altogether. found by Coverity
* pg_dump: Fix some minor memory leaksPeter Eisentraut2012-03-13
| | | | | | | | Although we often don't care about freeing all memory in pg_dump, these functions already freed the same memory in other code paths, so we might as well do it consistently. found by Coverity
* Patch some corner-case bugs in pl/python.Tom Lane2012-03-13
| | | | | | | | | | | | Dave Malcolm of Red Hat is working on a static code analysis tool for Python-related C code. It reported a number of problems in plpython, most of which were failures to check for NULL results from object-creation functions, so would only be an issue in very-low-memory situations. Patch in HEAD and 9.1. We could go further back but it's not clear that these issues are important enough to justify the work. Jan Urbański
* Fix minor memory leak in PLy_typeinfo_dealloc().Tom Lane2012-03-13
| | | | | | We forgot to free the per-attribute array element descriptors. Jan Urbański
* Create a stack of pl/python "execution contexts".Tom Lane2012-03-13
| | | | | | | | | | | | | | | | | This replaces the former global variable PLy_curr_procedure, and provides a place to stash per-call-level information. In particular we create a per-call-level scratch memory context. For the moment, the scratch context is just used to avoid leaking memory from datatype output function calls in PLyDict_FromTuple. There probably will be more use-cases in future. Although this is a fix for a pre-existing memory leakage bug, it seems sufficiently invasive to not want to back-patch; it feels better as part of the major rearrangement of plpython code that we've already done as part of 9.2. Jan Urbański
* Fix SPGiST vacuum algorithm to handle concurrent tuple motion properly.Tom Lane2012-03-12
| | | | | | | | | | | | | A leaf tuple that we need to delete could get moved as a consequence of an insertion happening concurrently with the VACUUM scan. If it moves from a page past the current scan point to a page before, we'll miss it, which is not acceptable. Hence, when we see a leaf-page REDIRECT that could have been made since our scan started, chase down the redirection pointer much as if we were doing a normal index search, and be sure to vacuum every page it leads to. This fixes the issue because, if the tuple was on page N at the instant we start our scan, we will surely find it as a consequence of chasing the redirect from page N, no matter how much it moves around in between. Problem noted by Takashi Yamamoto.
* Use correct sizeof operand in qsort callPeter Eisentraut2012-03-12
| | | | | Probably no practical impact, since all pointers ought to have the same size, but it was wrong nonetheless. Found by Coverity.
* Add comment for missing break in switchPeter Eisentraut2012-03-12
| | | | For clarity, following other sites, and to silence Coverity.