summaryrefslogtreecommitdiff
path: root/src/backend/commands
AgeCommit message (Collapse)Author
2007-09-16Fix aboriginal mistake in lazy VACUUM's code for truncating awayTom Lane
no-longer-needed pages at the end of a table. We thought we could throw away pages containing HEAPTUPLE_DEAD tuples; but this is not so, because such tuples very likely have index entries pointing at them, and we wouldn't have removed the index entries. The problem only emerges in a somewhat unlikely race condition: the dead tuples have to have been inserted by a transaction that later aborted, and this has to have happened between VACUUM's initial scan of the page and then rechecking it for empty in count_nondeletable_pages. But that timespan will include an index-cleaning pass, so it's not all that hard to hit. This seems to explain a couple of previously unsolved bug reports.
2007-09-12Fix the database-wide version of CLUSTER to silently skip temp tables ofAlvaro Herrera
remote sessions, instead of erroring out in the middle of the operation. This is a backpatch of a previous fix applied to CLUSTER to HEAD and 8.2, all the way back that it is relevant to.
2007-08-25Fix brain fade in DefineIndex(): it was continuing to access the table'sTom Lane
relcache entry after having heap_close'd it. This could lead to misbehavior if a relcache flush wiped out the cache entry meanwhile. In 8.2 there is a very real risk of CREATE INDEX CONCURRENTLY using the wrong relid for locking and waiting purposes. I think the bug is only cosmetic in 8.0 and 8.1, because their transgression is limited to using RelationGetRelationName(rel) in an ereport message immediately after heap_close, and there's no way (except with special debugging options) for a cache flush to occur in that interval. Not quite sure that it's cosmetic in 7.4, but seems best to patch anyway. Found by trying to run the regression tests with CLOBBER_CACHE_ALWAYS enabled. Maybe we should try to do that on a regular basis --- it's awfully slow, but perhaps some fast buildfarm machine could do it once in awhile.
2007-06-20CREATE DOMAIN ... DEFAULT NULL failed because gram.y special-cases DEFAULTTom Lane
NULL and DefineDomain didn't. Bug goes all the way back to original coding of domains. Per bug #3396 from Sergey Burladyan.
2007-03-14Fix a longstanding bug in VACUUM FULL's handling of update chains. The codeTom Lane
did not expect that a DEAD tuple could follow a RECENTLY_DEAD tuple in an update chain, but because the OldestXmin rule for determining deadness is a simplification of reality, it is possible for this situation to occur (implying that the RECENTLY_DEAD tuple is in fact dead to all observers, but this patch does not attempt to exploit that). The code would follow a chain forward all the way, but then stop before a DEAD tuple when backing up, meaning that not all of the chain got moved. This could lead to copying the chain multiple times (resulting in duplicate copies of the live tuple at its end), or leaving dangling index entries behind (which, aside from generating warnings from later vacuums, creates a risk of wrong query results or bogus duplicate-key errors once the heap slot the index entry points to is repopulated). The fix is to recheck HeapTupleSatisfiesVacuum while following a chain forward, and to stop if a DEAD tuple is reached. Each contiguous group of RECENTLY_DEAD tuples will therefore be copied as a separate chain. The patch also adds a couple of extra sanity checks to verify correct behavior. Per report and test case from Pavan Deolasee.
2007-02-06Fix an error in the original coding of holdable cursors: PersistHoldablePortalTom Lane
thought that it didn't have to reposition the underlying tuplestore if the portal is atEnd. But this is not so, because tuplestores have separate read and write cursors ... and the read cursor hasn't moved from the start. This mistake explains bug #2970 from William Zhang. Note: the coding here is pretty inefficient, but given that no one has noticed this bug until now, I'd say hardly anyone uses the case where the cursor has been advanced before being persisted. So maybe it's not worth worrying about.
2006-05-21Change the backend to reject strings containing invalidly-encoded multibyteTom Lane
characters in all cases. Formerly we mostly just threw warnings for invalid input, and failed to detect it at all if no encoding conversion was required. The tighter check is needed to defend against SQL-injection attacks as per CVE-2006-2313 (further details will be published after release). Embedded zero (null) bytes will be rejected as well. The checks are applied during input to the backend (receipt from client or COPY IN), so it no longer seems necessary to check in textin() and related routines; any string arriving at those functions will already have been validated. Conversion failure reporting (for characters with no equivalent in the destination encoding) has been cleaned up and made consistent while at it. Also, fix a few longstanding errors in little-used encoding conversion routines: win1251_to_iso, win866_to_iso, euc_tw_to_big5, euc_tw_to_mic, mic_to_euc_tw were all broken to varying extents. Patches by Tatsuo Ishii and Tom Lane. Thanks to Akio Ishida and Yasuo Ohgaki for identifying the security issues.
2006-02-12Fix bug in SET SESSION AUTHORIZATION that allows unprivileged users to crashTom Lane
the server, if it has been compiled with Asserts enabled (CVE-2006-0553). Thanks to Akio Ishida for reporting this problem.
2006-01-12Repair "Halloween problem" in EvalPlanQual: a tuple that's been inserted byTom Lane
our own command (or more generally, xmin = our xact and cmin >= current command ID) should not be seen as good. Else we may try to update rows we already updated. This error was inserted last August while fixing the even bigger problem that the old coding wouldn't see *any* tuples inserted by our own transaction as good. Per report from Euler Taveira de Oliveira.
2005-12-14Defend against crash while processing Describe Statement or Describe PortalTom Lane
messages, when client attempts to execute these outside a transaction (start one) or in a failed transaction (reject message, except for COMMIT/ROLLBACK statements which we can handle). Per report from Francisco Figueiredo Jr.
2005-10-03COPY's test for read-only transaction was backward; it prohibited COPY TOREL7_4_9Tom Lane
where it should prohibit COPY FROM. Found by Alon Goldshuv.
2005-08-25Back-patch fixes for problems with VACUUM destroying t_ctid chains too soon,Tom Lane
and with insufficient paranoia in code that follows t_ctid links. This patch covers the 7.4 branch.
2005-06-05Code for SET/SHOW TIME ZONE with a fixed-interval timezone was notTom Lane
prepared for HAVE_INT64_TIMESTAMP. Per report from Guillaume Beaudoin.
2005-05-07Repair very-low-probability race condition between relation extensionTom Lane
and VACUUM: in the interval between adding a new page to the relation and formatting it, it was possible for VACUUM to come along and decide it should format the page too. Though not harmful in itself, this would cause data loss if a third transaction were able to insert tuples into the vacuumed page before the original extender got control back.
2005-05-03Alter the signature for encoding conversion functions to declare theTom Lane
output area as INTERNAL not CSTRING. This is to prevent people from calling the functions by hand. This is a permanent solution for the back branches but I hope it is just a stopgap for HEAD.
2005-03-12Fix ALTER DATABASE RENAME to allow the operation if user is a superuserTom Lane
who for some reason isn't marked usecreatedb. Per report from Alexander Pravking. Also fix sloppy coding in have_createdb_privilege().
2005-02-14ALTER LANGUAGE RENAME has never worked. Per Sergey Yatskevich.Tom Lane
2005-02-06Repair CLUSTER failure after ALTER TABLE SET WITHOUT OIDS. Turns outTom Lane
there are corner cases involving dropping toasted columns in which the previous coding would fail, too: the new version of the table might not have any TOAST table, but we'd still propagate possibly-wide values of dropped columns forward.
2004-12-23Avoid memory leakage during VACUUM FULL when an index expression orTom Lane
index predicate uses temporary memory for evaluation. Per example from Jean-Gerard Pailloncy.
2004-12-13Back-patch copyOject fix for EXPLAIN/PREPARE.Tom Lane
2004-12-03Use StrNCpy not strncpy to fill hash key, to ensure the resulting keyTom Lane
is null-terminated. I think this is not a real bug because the parser would always have truncated the identifier to NAMEDATALEN-1 already, but let's be safe. Per report from Klocwork.
2004-11-28Avoid scribbling on original parsetree during DECLARE CURSOR. ThisTom Lane
prevents problems when the DECLARE is in a portal and is executed repeatedly, as is possible in v3 protocol. Per analysis by Oliver Jowett, though I didn't use his patch exactly.
2004-11-18Back-patch fix for ALTER DATABASE failing to flush pg_database changesTom Lane
to disk right away. This is just a one-liner change rather than trying to use FlushRelationBuffers().
2004-11-17Backpatch fix from HEAD:Neil Conway
Prevent a backend crash when processing CREATE TABLE commands with more than 65K columns, or when the created table has more than 65K columns due to adding inherited columns from parent relations. Fix a similar crash when processing SELECT queries with more than 65K target list entries. In all three cases we would eventually detect the error and elog, but the check was being made too late.
2004-08-31Repair 'expected both swapped tables to have TOAST tables' bug in 7.4Tom Lane
branch. I wasn't excited about doing this when the first report came in, but now that we have two of 'em, I suppose it had better get fixed.
2004-08-11Avoid crashing when restoring a saved GUC session_authorization valueTom Lane
that refers to a now-deleted userid. Per gripe from Chris Ochs.
2004-07-17When renaming a column that participates in a foreign key, we mustTom Lane
force relcache rebuild for the other table as well as the column's own table. Otherwise, already-cached foreign key triggers will stop working. Per example from Alexander Pravking.
2004-05-22Reduce pg_listener lock taken by NOTIFY et al from AccessExclusiveLockTom Lane
to ExclusiveLock. This still serializes the operations of this module, but doesn't conflict with concurrent ANALYZE operations. Per trouble report from Philip Warner a few weeks ago.
2004-04-06ALTER SEQUENCE RESTART did the wrong thing if sequence last_value wasTom Lane
equal to the desired restart value (must clear is_called, did not). Per bug report #1127 from Piotr Konieczny.
2004-02-21Implement a solution to the 'Turkish locale downcases I incorrectly'Tom Lane
problem, per previous discussion. Make some additional changes to centralize the knowledge of just how identifier downcasing is done, in hopes of simplifying any future tweaking in this area.
2004-01-18Don't use %s-with-precision format spec to truncate data being displayedTom Lane
in a COPY error message. It seems that glibc gets indigestion if it is asked to truncate strings that contain invalid UTF-8 encoding sequences. vsnprintf will return -1 in such cases, leading to looping and eventual memory overflow in elog.c. Instead use our own, more robust pg_mbcliplen routine. I believe this problem accounts for several recent reports of unexpected 'out of memory' errors during COPY IN.
2003-11-24Overdue code review for ALTER SEQUENCE patch. Don't generate illegal NodeTom Lane
tree for CYCLE option; don't assume zeros are invalid values for sequence fields other than increment_by; don't reset cache_value when not told to; simplify code for testing whether to apply defaults.
2003-10-18Simplify loop test to avoid bug in AIX compiler, per Andreas.Tom Lane
2003-10-17Adjust display of actual runtimes in EXPLAIN output to use three fractionalTom Lane
digits, and label it 'ms' not 'msec', for consistency with psql's \timing display. Per recent discussions.
2003-10-16Fix bad interaction between NOTIFY processing and V3 extended queryTom Lane
protocol, per report from Igor Shevchenko. NOTIFY thought it could do its thing if transaction blockState is TBLOCK_DEFAULT, but in reality it had better check the low-level transaction state is TRANS_DEFAULT as well. Formerly it was not possible to wait for the client in a state where the first is true and the second is not ... but now we can have such a state. Minor cleanup in StartTransaction() as well.
2003-10-13Back out makeNode() patch to fix gcc 3.3.1 warning.Bruce Momjian
2003-10-13Adjust setRelhassubclassInRelation() to not perform actual heap_updateTom Lane
when the pg_class.relhassubclass value is already correct. This should avoid most cases of the 'tuple concurrently updated' problem that Robert Creager recently complained about. Also remove a bunch of dead code in StoreCatalogInheritance() --- it was still computing the complete list of direct and indirect inheritance ancestors, though that list has not been needed since we got rid of the pg_ipl catalog.
2003-10-12Use makeNode() to allocate structures that have to be cast to Node *,Bruce Momjian
rather than allocating them on the stack. Fixes complaint from gcc 3.3.1.
2003-10-11Back out -fstrict-aliasing void* casting.Bruce Momjian
2003-10-11This patch will stop gcc from issuing warnings about type-punned objectsBruce Momjian
when -fstrict-aliasing is turned on, as it is in the latest gcc when you use -O2 Andrew Dunstan
2003-10-06During ALTER TABLE ADD FOREIGN KEY, try to check the existing rows usingTom Lane
a single LEFT JOIN query instead of firing the check trigger for each row individually. Stephan Szabo, with some kibitzing from Tom Lane and Jan Wieck.
2003-10-06Modify COPY FROM to match the null-value string against the column valueTom Lane
before it is de-backslashed, not after. This allows the null string \N to be reliably distinguished from the data value \N (which must be represented as \\N). Per bug report from Manfred Koizar ... but it's amazing this hasn't been reported before ... Also, be consistent about encoding conversion for null string: the form specified in the command is in the server encoding, but what is sent to/from client must be in client encoding. This never worked quite right before either.
2003-10-02Add a bit more locking to vac_update_relstats and vac_update_dbstatsTom Lane
to make them comparable to what UpdateStats does in the same situation. I'm not certain two instances of vac_update_relstats could run in parallel for the same relation, but parallel invocations of vac_update_dbstats do seem possible.
2003-10-02String fixes/improvements found by Alvaro HerreraPeter Eisentraut
2003-10-02Change some notices to warnings and vice versa according to criteriaPeter Eisentraut
developed on -hackers.
2003-10-01Repair RI trigger visibility problems (this time for sure ;-)) per recentTom Lane
discussion on pgsql-hackers: in READ COMMITTED mode we just have to force a QuerySnapshot update in the trigger, but in SERIALIZABLE mode we have to run the scan under a current snapshot and then complain if any rows would be updated/deleted that are not visible in the transaction snapshot.
2003-09-29Improve context display for failures during COPY IN, as recentlyTom Lane
discussed on pghackers.
2003-09-29Eliminate another gratuitous message wording difference.Peter Eisentraut
2003-09-29More message editing, some suggested by Alvaro HerreraPeter Eisentraut
2003-09-26Various message fixes, among those fixes for the previous round of fixesPeter Eisentraut