summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2011-07-20Support SECURITY LABEL on databases, tablespaces, and roles.Robert Haas
This requires a new shared catalog, pg_shseclabel. Along the way, fix the security_label regression tests so that they don't monkey with the labels of any pre-existing objects. This is unlikely to matter in practice, since only the label for the "dummy" provider was being manipulated. But this way still seems cleaner. KaiGai Kohei, with fairly extensive hacking by me.
2011-07-20Rewrite libxml error handling to be more robust.Tom Lane
libxml reports some errors (like invalid xmlns attributes) via the error handler hook, but still returns a success indicator to the library caller. This causes us to miss some errors that are important to report. Since the "generic" error handler hook doesn't know whether the message it's getting is for an error, warning, or notice, stop using that and instead start using the "structured" error handler hook, which gets enough information to be useful. While at it, arrange to save and restore the error handler hook setting in each libxml-using function, rather than assuming we can set and forget the hook. This should improve the odds of working nicely with third-party libraries that also use libxml. In passing, volatile-ize some local variables that get modified within PG_TRY blocks. I noticed this while testing with an older gcc version than I'd previously tried to compile xml.c with. Florian Pflug and Tom Lane, with extensive review/testing by Noah Misch
2011-07-19Make isolationtester more robust on locked commandsAlvaro Herrera
Noah Misch diagnosed the buildfarm problems in the isolation tests partly as failure to differentiate backends properly; the old code was using backend IDs, which is not good enough because a new backend might use an already used ID. Use PIDs instead. Also, the code was purposely careless about other concurrent activity, because it isn't expected; and in fact, it doesn't affect the vast majority of the time. However, it can be observed that autovacuum can block tables for long enough to cause sporadic failures. The new code accounts for that by ignoring locks held by processes not explicitly declared in our spec file. Author: Noah Misch
2011-07-19Increase deadlock_timeout to 100ms in FK isolation testsAlvaro Herrera
The previous value of 20ms is dangerously close to the time actually spent just waiting for the deadlock to happen, so on occasion it causes the test to fail simply because the other session didn't get to run early enough, not managing to cause the deadlock that needs to be detected. With this new value, it's expected that most machines on normal load will be able to pass the test. Author: Noah Misch
2011-07-19Add expected regress output on stricter isolation levelsAlvaro Herrera
These new files allow the new FK tests on isolationtester to pass on the serializable and repeatable read isolation levels (which are untested by the buildfarm). Author: Kevin Grittner Reviewed by Noah Misch
2011-07-19Fix typoPeter Eisentraut
2011-07-18Add GET STACKED DIAGNOSTICS plpgsql command to retrieve exception info.Tom Lane
This is more SQL-spec-compliant, more easily extensible, and better performing than the old method of inventing special variables. Pavel Stehule, reviewed by Shigeru Hanada and David Wheeler
2011-07-18Create a "fast path" for acquiring weak relation locks.Robert Haas
When an AccessShareLock, RowShareLock, or RowExclusiveLock is requested on an unshared database relation, and we can verify that no conflicting locks can possibly be present, record the lock in a per-backend queue, stored within the PGPROC, rather than in the primary lock table. This eliminates a great deal of contention on the lock manager LWLocks. This patch also refactors the interface between GetLockStatusData() and pg_lock_status() to be a bit more abstract, so that we don't rely so heavily on the lock manager's internal representation details. The new fast path lock structures don't have a LOCK or PROCLOCK structure to return, so we mustn't depend on that for purposes of listing outstanding locks. Review by Jeff Davis.
2011-07-15Set different deadlock_timeout on each session in new isolation testsAlvaro Herrera
This provides deterministic deadlock-detection ordering for new isolation tests, fixing the sporadic failures in them. Author: Noah Misch
2011-07-12Avoid listing ungrouped Vars in the targetlist of Agg-underneath-Window.Tom Lane
Regular aggregate functions in combination with, or within the arguments of, window functions are OK per spec; they have the semantics that the aggregate output rows are computed and then we run the window functions over that row set. (Thus, this combination is not really useful unless there's a GROUP BY so that more than one aggregate output row is possible.) The case without GROUP BY could fail, as recently reported by Jeff Davis, because sloppy construction of the Agg node's targetlist resulted in extra references to possibly-ungrouped Vars appearing outside the aggregate function calls themselves. See the added regression test case for an example. Fixing this requires modifying the API of flatten_tlist and its underlying function pull_var_clause. I chose to make pull_var_clause's API for aggregates identical to what it was already doing for placeholders, since the useful behaviors turn out to be the same (error, report node as-is, or recurse into it). I also tightened the error checking in this area a bit: if it was ever valid to see an uplevel Var, Aggref, or PlaceHolderVar here, that was a long time ago, so complain instead of ignoring them. Backpatch into 9.1. The failure exists in 8.4 and 9.0 as well, but seeing that it only occurs in a basically-useless corner case, it doesn't seem worth the risks of changing a function API in a minor release. There might be third-party code using pull_var_clause.
2011-07-12Add support for blocked commands in isolationtesterAlvaro Herrera
This enables us to test that blocking commands (such as foreign keys checks that conflict with some other lock) act as intended. The set of tests that this adds is pretty minimal, but can easily be extended by adding new specs. The intention is that this will serve as a basis for ensuring that further tweaks of locking implementation preserve (or improve) existing behavior. Author: Noah Misch
2011-07-08Message style improvementsPeter Eisentraut
2011-07-07Fix a bug with SSI and prepared transactions:Heikki Linnakangas
If there's a dangerous structure T0 ---> T1 ---> T2, and T2 commits first, we need to abort something. If T2 commits before both conflicts appear, then it should be caught by OnConflict_CheckForSerializationFailure. If both conflicts appear before T2 commits, it should be caught by PreCommit_CheckForSerializationFailure. But that is actually run when T2 *prepares*. Fix that in OnConflict_CheckForSerializationFailure, by treating a prepared T2 as if it committed already. This is mostly a problem for prepared transactions, which are in prepared state for some time, but also for regular transactions because they also go through the prepared state in the SSI code for a short moment when they're committed. Kevin Grittner and Dan Ports
2011-07-04Message style tweaksPeter Eisentraut
2011-07-04Move Trigger and TriggerDesc structs out of rel.h into a new reltrigger.hAlvaro Herrera
This lets us stop including rel.h into execnodes.h, which is a widely used header.
2011-07-04Alter test results to comply with new ALTER TABLE behaviour.Simon Riggs
2011-07-03Fix bugs in relpersistence handling during table creation.Robert Haas
Unlike the relistemp field which it replaced, relpersistence must be set correctly quite early during the table creation process, as we rely on it quite early on for a number of purposes, including security checks. Normally, this is set based on whether the user enters CREATE TABLE, CREATE UNLOGGED TABLE, or CREATE TEMPORARY TABLE, but a relation may also be made implicitly temporary by creating it in pg_temp. This patch fixes the handling of that case, and also disables creation of unlogged tables in temporary tablespace (such table indeed skip WAL-logging, but we reject an explicit specification) and creation of relations in the temporary schemas of other sessions (which is not very sensible, and didn't work right anyway). Report by Amit Khandekar.
2011-06-30Enable CHECK constraints to be declared NOT VALIDAlvaro Herrera
This means that they can initially be added to a large existing table without checking its initial contents, but new tuples must comply to them; a separate pass invoked by ALTER TABLE / VALIDATE can verify existing data and ensure it complies with the constraint, at which point it is marked validated and becomes a normal part of the table ecosystem. An non-validated CHECK constraint is ignored in the planner for constraint_exclusion purposes; when validated, cached plans are recomputed so that partitioning starts working right away. This patch also enables domains to have unvalidated CHECK constraints attached to them as well by way of ALTER DOMAIN / ADD CONSTRAINT / NOT VALID, which can later be validated with ALTER DOMAIN / VALIDATE CONSTRAINT. Thanks to Thom Brown, Dean Rasheed and Jaime Casanova for the various reviews, and Robert Hass for documentation wording improvement suggestions. This patch was sponsored by Enova Financial.
2011-06-29Restore correct btree preprocessing of "indexedcol IS NULL" conditions.Tom Lane
Such a condition is unsatisfiable in combination with any other type of btree-indexable condition (since we assume btree operators are always strict). 8.3 and 8.4 had an explicit test for this, which I removed in commit 29c4ad98293e3c5cb3fcdd413a3f4904efff8762, mistakenly thinking that the case would be subsumed by the more general handling of IS (NOT) NULL added in that patch. Put it back, and improve the comments about it, and add a regression test case. Per bug #6079 from Renat Nasyrov, and analysis by Dean Rasheed.
2011-06-29Unify spelling of "canceled", "canceling", "cancellation"Peter Eisentraut
We had previously (af26857a2775e7ceb0916155e931008c2116632f) established the U.S. spellings as standard.
2011-06-22Update alternative expected file for recent sequence test changes.Tom Lane
2011-06-22Revert "Don't select log_cnt in sequence regression tests."Tom Lane
This reverts commit addf11f9a264417aa467d4e135b9a8afc59f172a. The right fix for the problem is to update the alternative expected file, not to lobotomize the test case.
2011-06-22Don't select log_cnt in sequence regression tests.Robert Haas
It's not entirely stable. Per suggestion from Josh Kupershmidt.
2011-06-22Add some regression tests for serial pseudotypes.Robert Haas
Josh Kupershmidt
2011-06-21Message style and spelling improvementsPeter Eisentraut
2011-06-21Adjust the alternative expected output file for prepared_xacts test case,Heikki Linnakangas
used when max_prepared_transactions=0, for the recent changes in the test case.
2011-06-21Fix bug in PreCommit_CheckForSerializationFailure. A transaction that hasHeikki Linnakangas
already been marked as PREPARED cannot be killed. Kill the current transaction instead. One of the prepared_xacts regression tests actually hits this bug. I removed the anomaly from the duplicate-gids test so that it fails in the intended way, and added a new test to check serialization failures with a prepared transaction. Dan Ports
2011-06-20Fix thinko in previous patch for optimizing EXISTS-within-EXISTS.Tom Lane
When recursing after an optimization in pull_up_sublinks_qual_recurse, the available_rels value passed down must include only the relations that are in the righthand side of the new SEMI or ANTI join; it's incorrect to pull up a sub-select that refers to other relations, as seen in the added test case. Per report from BangarRaju Vadapalli. While at it, rethink the idea of recursing below a NOT EXISTS. That is essentially the same situation as pulling up ANY/EXISTS sub-selects that are in the ON clause of an outer join, and it has the same disadvantage: we'd force the two joins to be evaluated according to the syntactic nesting order, because the lower join will most likely not be able to commute with the ANTI join. That could result in having to form a rather large join product, whereas the handling of a correlated subselect is not quite that dumb. So until we can handle those cases better, #ifdef NOT_USED that case. (I think it's okay to pull up in the EXISTS/ANY cases, because SEMI joins aren't so inflexible about ordering.) Back-patch to 8.4, same as for previous patch in this area. Fortunately that patch hadn't made it into any shipped releases yet.
2011-06-18Capitalization fixesPeter Eisentraut
2011-06-16Use single quotes in preference to double quotes for protecting pathnames.Tom Lane
Per recommendation from Peter. Neither choice is bulletproof, but this is the existing style and it does help prevent unexpected environment variable substitution.
2011-06-14Fix assorted issues with build and install paths containing spaces.Tom Lane
Apparently there is no buildfarm critter exercising this case after all, because it fails in several places. With this patch, build, install, check-world, and installcheck-world pass for me on OS X.
2011-06-09Pgindent run before 9.1 beta2.Bruce Momjian
2011-06-08Allow domains over arrays to match ANYARRAY parameters again.Tom Lane
This use-case was broken in commit 529cb267a6843a6a8190c86b75d091771d99d6a9 of 2010-10-21, in which I commented "For the moment, we just forbid such matching. We might later wish to insert an automatic downcast to the underlying array type, but such a change should also change matching of domains to ANYELEMENT for consistency". We still lack consensus about what to do with ANYELEMENT; but not matching ANYARRAY is a clear loss of functionality compared to prior releases, so let's go ahead and make that happen. Per complaint from Regina Obe and extensive subsequent discussion.
2011-06-07Fix rewriter to cope (more or less) with CTEs in the query being rewritten.Tom Lane
Since the original implementation of CTEs only allowed them in SELECT queries, the rule rewriter did not expect to find any CTEs in statements being rewritten by ON INSERT/UPDATE/DELETE rules. We had dealt with this to some extent but the code was still several bricks shy of a load, as illustrated in bug #6051 from Jehan-Guillaume de Rorthais. In particular, we have to be able to copy CTEs from the original query's cteList into that of a rule action, in case the rule action references the CTE (which it pretty much always will). This also implies we were doing things in the wrong order in RewriteQuery: we have to recursively rewrite the CTE queries before expanding the main query, so that we have the rewritten queries available to copy. There are unpleasant limitations yet to resolve here, but at least we now throw understandable FEATURE_NOT_SUPPORTED errors for them instead of just failing with bizarre implementation-dependent errors. In particular, we can't handle propagating the same CTE into multiple post-rewrite queries (because then the CTE would be evaluated multiple times), and we can't cope with conflicts between CTE names in the original query and in the rule actions.
2011-06-06Reset reindex-in-progress state before reverifying an exclusion constraint.Tom Lane
This avoids an Assert failure when we try to use ordinary index fetches while checking for exclusion conflicts. Per report from Noah Misch. No need for back-patch because the Assert wasn't there before 9.1.
2011-06-03Fix failure to check whether a rowtype's component types are sortable.Tom Lane
The existence of a btree opclass accepting composite types caused us to assume that every composite type is sortable. This isn't true of course; we need to check if the column types are all sortable. There was logic for this for the case of array comparison (ie, check that the element type is sortable), but we missed the point for rowtypes. Per Teodor's report of an ANALYZE failure for an unsortable composite type. Rather than just add some more ad-hoc logic for this, I moved knowledge of the issue into typcache.c. The typcache will now only report out array_eq, record_cmp, and friends as usable operators if the array or composite type will work with those functions. Unfortunately we don't have enough info to do this for anonymous RECORD types; in that case, just assume it will work, and take the runtime failure as before if it doesn't. This patch might be a candidate for back-patching at some point, but given the lack of complaints from the field, I'd rather just test it in HEAD for now. Note: most of the places touched in this patch will need further work when we get around to supporting hashing of record types.
2011-06-02Handle domains when checking for recursive inclusion of composite types.Tom Lane
We need this now because we allow domains over arrays, and we'll probably allow domains over composites pretty soon, which makes the problem even more obvious. Although domains over arrays also exist in previous versions, this does not need to be back-patched, because the coding used in older versions successfully "looked through" domains over arrays. The problem is exposed by not treating a domain as having a typelem. Problem identified by Noah Misch, though I did not use his patch, since it would require additional work to handle domains over composites that way. This approach is more future-proof.
2011-05-30The row-version chaining in Serializable Snapshot Isolation was still wrong.Heikki Linnakangas
On further analysis, it turns out that it is not needed to duplicate predicate locks to the new row version at update, the lock on the version that the transaction saw as visible is enough. However, there was a different bug in the code that checks for dangerous structures when a new rw-conflict happens. Fix that bug, and remove all the row-version chaining related code. Kevin Grittner & Dan Ports, with some comment editorialization by me.
2011-05-27Check the return code of pthread_create(). Otherwise we go into an infiniteHeikki Linnakangas
loop if it fails, which is what what happened on my HP-UX box. (I think the reason it failed on that box is a misconfiguration on my behalf, but that's no reason to hang.)
2011-05-24Grammar cleanup for src/test/isolation/READMETom Lane
Josh Kupershmidt
2011-05-22Use the right pgsql for isolation tests.Andrew Dunstan
2011-05-21In binary-upgrade mode, dump dropped attributes of composite types.Heikki Linnakangas
Noah Misch
2011-05-20Message style improvementsPeter Eisentraut
2011-05-18Spell checking and markup refinementPeter Eisentraut
2011-05-16Quote isolationtester command name so Windows will not think dot is the command.Andrew Dunstan
2011-05-15Fix bad macro call noticed by MSVC compiler.Andrew Dunstan
2011-05-09Remove "make check" target in src/test/isolation/Makefile.Tom Lane
This doesn't work as expected because the isolationtester program requires libpq to already be installed. While it works when you've already installed libpq, having to already have done "make install" defeats most of the point of a check with a temp installation. And there are weird corner cases if the dynamic linker picks up an old libpq.so from system library directories. Remove the target (or more precisely, make it print a helpful message) so people don't expect the case to work.
2011-05-08Fix some portability issues in isolation regression test driver.Tom Lane
Remove random system #includes in favor of using postgres_fe.h. (The alternative to that is letting this module grow its own configuration testing ability...) Also fix the "make clean" target to actually clean things up. Per local testing.
2011-05-05Unbreak the regression tests from my previous commitMagnus Hagander
2011-04-28Use a macro variable PG_PRINTF_ATTRIBUTE for the style used for checking ↵Andrew Dunstan
printf type functions. The style is set to "printf" for backwards compatibility everywhere except on Windows, where it is set to "gnu_printf", which eliminates hundreds of false error messages from modern versions of gcc arising from %m and %ll{d,u} formats.