summaryrefslogtreecommitdiff
path: root/src/backend/commands
AgeCommit message (Collapse)Author
2005-04-11Fix interaction between materializing holdable cursors and firingTom Lane
deferred triggers: either one can create more work for the other, so we have to loop till it's all gone. Per example from andrew@supernews. Add a regression test to help spot trouble in this area in future.
2005-04-11PersistHoldablePortal must establish the correct value for ActiveSnapshotTom Lane
while completing execution of the cursor's query. Otherwise we get wrong answers or even crashes from non-volatile functions called by the query. Per report from andrew@supernews.
2005-03-25Remove lazy_update_relstats; go back to having VACUUM just record theTom Lane
actual number of unremoved tuples as pg_class.reltuples. The idea of trying to estimate a steady state condition still seems attractive, but this particular implementation crashed and burned ...
2005-03-25Fix two bugs in change_owner_recurse_to_sequences: it was grabbing anTom Lane
overly strong lock on pg_depend, and it wasn't closing the rel when done. The latter bug was masked by the ResourceOwner code, which is something that should be changed.
2005-03-23WAL must log CREATE and DROP DATABASE operations *without* using anyTom Lane
explicit paths, so that the log can be replayed in a data directory with a different absolute path than the original had. To avoid forcing initdb in the 8.0 branch, continue to accept the old WAL log record types; they will never again be generated however, and the code can be dropped after the next forced initdb. Per report from Oleg Bartunov. We still need to think about what it really means to WAL-log CREATE TABLESPACE commands: we more or less have to put the absolute path into those, but how to replay in a different context??
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-09ALTER TABLE ADD COLUMN exhibits a significant memory leak when adding aNeil Conway
column with a default expression. In that situation, we need to rewrite the heap relation. To evaluate the new default expression, we use ExecEvalExpr(); however, this can allocate memory in the current memory context, and ATRewriteTable() does not switch out of the active portal's heap memory context. The end result is a rather large memory leak (on the order of gigabytes for a reasonably sized table). This patch changes ATRewriteTable() to switch to the per-tuple memory context before beginning the per-tuple loop. It also removes an explicit heap_freetuple() in the loop, since that is no longer needed. In an unrelated change, I noticed the code was scanning through the attributes of the new tuple descriptor for each tuple of the old table. I changed this to use precomputation, which should slightly speed up the loop. Thanks to steve@deefs.net for reporting the leak.
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.
2005-01-24Fix ALTER TABLE ADD COLUMN so that constraints of domain types areTom Lane
enforced properly when there is no explicit default value for the new column. Per report from Craig Perras.
2005-01-10Phase 1 of fix for 'SMgrRelation hashtable corrupted' problem. ThisTom Lane
is the minimum required fix. I want to look next at taking advantage of it by simplifying the message semantics in the shared inval message queue, but that part can be held over for 8.1 if it turns out too ugly.
2005-01-01Update copyrights that were missed.Bruce Momjian
2004-12-31Tag appropriate files for rc3PostgreSQL Daemon
Also performed an initial run through of upgrading our Copyright date to extend to 2005 ... first run here was very simple ... change everything where: grep 1996-2004 && the word 'Copyright' ... scanned through the generated list with 'less' first, and after, to make sure that I only picked up the right entries ...
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-12PREPARE and EXPLAIN need to copy the source query just like we recentlyTom Lane
had to do in DECLARE CURSOR. AFAICS these are all the places affected. PREPARE case per example from Michael Fuhr, EXPLAIN case located by grepping for planner calls ...
2004-12-06ActiveSnapshot must be set to something valid while running deferredTom Lane
triggers during COMMIT. Per trouble report from Frank van Vugt.
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-12-03> If it bothers you that much. I'd make a flag, cleared at the start ofBruce Momjian
> each COPY, and then where we test for CR or LF in CopyAttributeOutCSV, > if the flag is not set then set it and issue the warning. Andrew Dunstan
2004-12-02Disallow the combination VACUUM FULL FREEZE for safety's sake, for theTom Lane
reasons I outlined in pghackers a few days ago. Also, undo someone's overly optimistic decision to reduce tuple state checks from if (...) elog() to Asserts. If I trusted this code more, I might think it was a good idea to disable these checks in production installations. But I don't.
2004-12-01Change planner to use the current true disk file size as its estimate ofTom Lane
a relation's number of blocks, rather than the possibly-obsolete value in pg_class.relpages. Scale the value in pg_class.reltuples correspondingly to arrive at a hopefully more accurate number of rows. When pg_class contains 0/0, estimate a tuple width from the column datatypes and divide that into current file size to estimate number of rows. This improved methodology allows us to jettison the ancient hacks that put bogus default values into pg_class when a table is first created. Also, per a suggestion from Simon, make VACUUM (but not VACUUM FULL or ANALYZE) adjust the value it puts into pg_class.reltuples to try to represent the mean tuple density instead of the minimal density that actually prevails just after VACUUM. These changes alter the plans selected for certain regression tests, so update the expected files accordingly. (I removed join_1.out because it's not clear if it still applies; we can add back any variant versions as they are shown to be needed.)
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-18Force pg_database updates out to disk immediately after ALTER DATABASE;Tom Lane
this is to avoid scenarios where incoming backends find no live copies of a database's row because the only live copy is in an as-yet-unwritten shared buffer, which they can't see. Also, use FlushRelationBuffers() for forcing out pg_database, instead of the much more expensive BufferSync(). There's no need to write out pages belonging to other relations.
2004-11-16Prevent a backend crash when processing CREATE TABLE commands withNeil Conway
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-11-14There is no need for ReadBuffer() call sites to check that the returnedNeil Conway
buffer is valid, as ReadBuffer() will elog on error. Most of the call sites of ReadBuffer() got this right, but this patch fixes those call sites that did not.
2004-11-06When implementing a coercion to a domain type with a combinedTom Lane
type-and-length coercion function, make sure that the coercion function is told the correct typmod. Fixes Kris Jurka's example of a domain over bit(N).
2004-11-05Create 'default_tablespace' GUC variable that supplies a TABLESPACETom Lane
clause implicitly whenever one is not given explicitly. Remove concept of a schema having an associated tablespace, and simplify the rules for selecting a default tablespace for a table or index. It's now just (a) explicit TABLESPACE clause; (b) default_tablespace if that's not an empty string; (c) database's default. This will allow pg_dump to use SET commands instead of tablespace clauses to determine object locations (but I didn't actually make it do so). All per recent discussions.
2004-11-05Small message clarificationsPeter Eisentraut
2004-10-30I found a corner case in which it is possible for RI_FKey_check's callTom Lane
of HeapTupleSatisfiesItself() to trigger a hint-bit update on the tuple: if the row was updated or deleted by a subtransaction of my own transaction that was later rolled back. This cannot occur in pre-8.0 of course, so the hint-bit patch applied a couple weeks ago is OK for existing releases. But for 8.0 it seems we had better fix things so that RI_FKey_check can pass the correct buffer number to HeapTupleSatisfiesItself. Accordingly, add fields to the TriggerData struct to carry the buffer ID(s) for the old and new tuple(s). There are other possible solutions but this one seems cleanest; it will allow other AFTER-trigger functions to safely do tqual.c calls if they want to. Put new fields at end of struct so that there is no API breakage.
2004-10-29Fix failure to think clearly about encoding conversion errors in COPY.Tom Lane
We can't regurgitate the unconverted string as I first thought, because the elog.c mechanisms will assume the error message data is in the server encoding and attempt a reverse conversion. Eventually it might be worth providing a short-circuit path to support this, but for now the simplest solution is to abandon trying to report back the line contents after a conversion failure. Per bug report from Sil Lee, 27-Oct-2004.
2004-10-28On Windows, force a checkpoint just before dropping a database's physicalTom Lane
files and directories. This ensures that the bgwriter will close any open file references it is holding for files therein, which is needed for the rmdir() to succeed. Andrew Dunstan and Tom Lane.
2004-10-26Make heap_fetch API more consistent by having the buffer remain pinnedTom Lane
in all cases when keep_buf = true. This allows ANALYZE's inner loop to use heap_release_fetch, which saves multiple buffer lookups for the same page and avoids overestimation of cost by the vacuum cost mechanism.
2004-10-25In the new dispensation where REINDEX doesn't take exclusive lock onTom Lane
the parent table, it's essential that all index accesses take some kind of lock on the index. I had missed vacuumlazy.c :-( ...
2004-10-25Modify hash_create() to elog(ERROR) if an error occurs, rather thanNeil Conway
returning a NULL pointer (some callers remembered to check the return value, but some did not -- it is safer to just bail out). Also, cleanup pgstat.c to use elog(ERROR) rather than elog(LOG) followed by exit().
2004-10-22In ALTER COLUMN TYPE, strip any implicit coercion operations appearingTom Lane
at the top level of the column's old default expression before adding an implicit coercion to the new column type. This seems to satisfy the principle of least surprise, as per discussion of bug #1290.
2004-10-21Disallow referential integrity actions from being deferred; only theTom Lane
NO ACTION check is deferrable. This seems to be a closer approximation to what the SQL spec says than what we were doing before, and it prevents some anomalous behaviors that are possible now that triggers can fire during the execution of PL functions. Stephan Szabo.
2004-10-17Give a more user-friendly error message in situation where CREATE DATABASETom Lane
specifies a new default tablespace and the template database already has some tables in that tablespace. There isn't any way to solve this fully without modifying the clone database's pg_class contents, so for now the best we can do is issue a better error message.
2004-10-16Give a more user-friendly error message in case where a table is createdTom Lane
in a schema whose default tablespace has been dropped.
2004-10-15Repair possible failure to update hint bits back to disk, perTom Lane
http://archives.postgresql.org/pgsql-hackers/2004-10/msg00464.php. This fix is intended to be permanent: it moves the responsibility for calling SetBufferCommitInfoNeedsSave() into the tqual.c routines, eliminating the requirement for callers to test whether t_infomask changed. Also, tighten validity checking on buffer IDs in bufmgr.c --- several routines were paranoid about out-of-range shared buffer numbers but not about out-of-range local ones, which seems a tad pointless.
2004-10-12Message style revisionsPeter Eisentraut
2004-10-07Adjust comments previously moved to column 1 by pgident.Bruce Momjian
2004-10-07Back out unindented modification to file.Bruce Momjian
2004-10-07Indent comment pushed to new line by else so it is indented by BSDBruce Momjian
indent.
2004-09-30Adjust index locking rules as per my proposal of earlier today. YouTom Lane
now are supposed to take some kind of lock on an index whenever you are going to access the index contents, rather than relying only on a lock on the parent table.
2004-09-30Remove unnecessary use of index_open just to get the index name.Tom Lane
2004-09-27Code cleanup: don't bother casting the argument to pfree() to void *Neil Conway
from another pointer type. Per C89, this is unnecessary, and it is common practice throughout the rest of the tree anyway.
2004-09-24GUC assign hooks that look at external state in deciding whether aTom Lane
setting is valid must ignore that state and permit the assignment anyway when source is PGC_S_OVERRIDE. Otherwise they may disallow a rollback at transaction abort, which is The Wrong Thing. Per example from Michael Fuhr 12-Sep-04.
2004-09-23Fix ALTER TABLE OWNER to adjust the ownership of dependent sequences,Tom Lane
not only indexes. Alvaro Herrera, with some kibitzing by Tom Lane.
2004-09-16Restructure subtransaction handling to reduce resource consumption,Tom Lane
as per recent discussions. Invent SubTransactionIds that are managed like CommandIds (ie, counter is reset at start of each top transaction), and use these instead of TransactionIds to keep track of subtransaction status in those modules that need it. This means that a subtransaction does not need an XID unless it actually inserts/modifies rows in the database. Accordingly, don't assign it an XID nor take a lock on the XID until it tries to do that. This saves a lot of overhead for subtransactions that are only used for error recovery (eg plpgsql exceptions). Also, arrange to release a subtransaction's XID lock as soon as the subtransaction exits, in both the commit and abort cases. This avoids holding many unique locks after a long series of subtransactions. The price is some additional overhead in XactLockTableWait, but that seems acceptable. Finally, restructure the state machine in xact.c to have a more orthogonal set of states for subtransactions.
2004-09-13Redesign query-snapshot timing so that volatile functions in READ COMMITTEDTom Lane
mode see a fresh snapshot for each command in the function, rather than using the latest interactive command's snapshot. Also, suppress fresh snapshots as well as CommandCounterIncrement inside STABLE and IMMUTABLE functions, instead using the snapshot taken for the most closely nested regular query. (This behavior is only sane for read-only functions, so the patch also enforces that such functions contain only SELECT commands.) As per my proposal of 6-Sep-2004; I note that I floated essentially the same proposal on 19-Jun-2002, but that discussion tailed off without any action. Since 8.0 seems like the right place to be taking possibly nontrivial backwards compatibility hits, let's get it done now.
2004-09-11Renumber SnapshotNow and the other special snapshot codes so thatTom Lane
((Snapshot) NULL) can no longer be confused with a valid snapshot, as per my recent suggestion. Define a macro InvalidSnapshot for 0. Use InvalidSnapshot instead of SnapshotAny as the do-nothing special case for heap_update and heap_delete crosschecks; this seems a little cleaner even though the behavior is really the same.