aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
Commit message (Collapse)AuthorAge
...
* Replace the parser's namespace tree (which formerly had the sameTom Lane2005-06-05
| | | | | | | | | representation as the jointree) with two lists of RTEs, one showing the RTEs accessible by qualified names, and the other showing the RTEs accessible by unqualified names. I think this is conceptually simpler than what we did before, and it's sure a whole lot easier to search. This seems to eliminate the parse-time bottleneck for deeply nested JOIN structures that was exhibited by phil@vodafone.
* When enqueueing after-row triggers for updates of a table with a foreignNeil Conway2005-05-30
| | | | | | | | | | | | key, compare the new and old row versions. If the foreign key column has not changed, we needn't enqueue the trigger, since the update cannot violate the foreign key. This optimization was previously applied in the RI trigger function, but it is more efficient to avoid firing the trigger altogether. Per recent discussion on pgsql-hackers. Also add a regression test for some unintuitive foreign key behavior, and refactor some code that deals with the OIDs of the various RI trigger functions.
* Create separate ON INSERT and ON UPDATE triggers on tables with foreignNeil Conway2005-05-30
| | | | | | | | | | keys, rather than a single trigger for both events. This should not change functionality, but it is more consistent: previously, there were trigger functions for both "check_insert" and "check_update", but the former was used for both events. Bump catalog version number (not strictly necessary, but best to be cautious).
* Report index name on CLUSTER failure. Also, suggest ALTER TABLEBruce Momjian2005-05-10
| | | | | WITHOUT CLUSTER for cluster failure of a single table in a full db cluster.
* For some reason access/tupmacs.h has been #including utils/memutils.h,Tom Lane2005-05-06
| | | | | | | which is neither needed by nor related to that header. Remove the bogus inclusion and instead include the header in those C files that actually need it. Also fix unnecessary inclusions and bad inclusion order in tsearch2 files.
* Completion of project to use fixed OIDs for all system catalogs andTom Lane2005-04-14
| | | | | | | indexes. Replace all heap_openr and index_openr calls by heap_open and index_open. Remove runtime lookups of catalog OID numbers in various places. Remove relcache's support for looking up system catalogs by name. Bulky but mostly very boring patch ...
* First phase of project to use fixed OIDs for all system catalogs andTom Lane2005-04-14
| | | | | | | | | | | | | | | | indexes. Extend the macros in include/catalog/*.h to carry the info about hand-assigned OIDs, and adjust the genbki script and bootstrap code to make the relations actually get those OIDs. Remove the small number of RelOid_pg_foo macros that we had in favor of a complete set named like the catname.h and indexing.h macros. Next phase will get rid of internal use of names for looking up catalogs and indexes; but this completes the changes forcing an initdb, so it looks like a good place to commit. Along the way, I made the shared relations (pg_database etc) not be 'bootstrap' relations any more, so as to reduce the number of hardwired entries and simplify changing those relations in future. I'm not sure whether they ever really needed to be handled as bootstrap relations, but it seems to work fine to not do so now.
* Change addRangeTableEntryForRelation() to take a Relation pointer insteadTom Lane2005-04-13
| | | | | | | | | | of just a relation OID, thereby not having to open the relation for itself. This actually saves code rather than adding it for most of the existing callers, which had the rel open already. The main point though is to be able to use this rather than plain addRangeTableEntry in setTargetTable, thus saving one relation_openrv/relation_close cycle for every INSERT, UPDATE, or DELETE. Seems to provide a several percent win on simple INSERTs.
* Convert oidvector and int2vector into variable-length arrays. ThisTom Lane2005-03-29
| | | | | | | | | | | | | change saves a great deal of space in pg_proc and its primary index, and it eliminates the former requirement that INDEX_MAX_KEYS and FUNC_MAX_ARGS have the same value. INDEX_MAX_KEYS is still embedded in the on-disk representation (because it affects index tuple header size), but FUNC_MAX_ARGS is not. I believe it would now be possible to increase FUNC_MAX_ARGS at little cost, but haven't experimented yet. There are still a lot of vestigial references to FUNC_MAX_ARGS, which I will clean up in a separate pass. However, getting rid of it altogether would require changing the FunctionCallInfoData struct, and I'm not sure I want to buy into that.
* Fix two bugs in change_owner_recurse_to_sequences: it was grabbing anTom Lane2005-03-25
| | | | | | 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.
* Revert changes to CREATE TRIGGER and ALTER TABLE ADD FOREIGN KEY locking,Neil Conway2005-03-24
| | | | per request from Tom.
* Adjust CREATE TRIGGER and ALTER TABLE ... ADD FOREIGN KEY to acquireNeil Conway2005-03-23
| | | | | | ExclusiveLock rather than AccessExclusiveLock. This will allow concurrent SELECT queries to proceed on the table. Per discussion with Andrew at SuperNews.
* Remove unnecessary calls of FlushRelationBuffers: there is no needTom Lane2005-03-20
| | | | | | | | | | to write out data that we are about to tell the filesystem to drop. smgr_internal_unlink already had a DropRelFileNodeBuffers call to get rid of dead buffers without a write after it's no longer possible to roll back the deleting transaction. Adding a similar call in smgrtruncate simplifies callers and makes the overall division of labor clearer. This patch removes the former behavior that VACUUM would write all dirty buffers of a relation unconditionally.
* Revise TupleTableSlot code to avoid unnecessary construction and disassemblyTom Lane2005-03-16
| | | | | | | | | | | | | | | | | | | | | of tuples when passing data up through multiple plan nodes. A slot can now hold either a normal "physical" HeapTuple, or a "virtual" tuple consisting of Datum/isnull arrays. Upper plan levels can usually just copy the Datum arrays, avoiding heap_formtuple() and possible subsequent nocachegetattr() calls to extract the data again. This work extends Atsushi Ogawa's earlier patch, which provided the key idea of adding Datum arrays to TupleTableSlots. (I believe however that something like this was foreseen way back in Berkeley days --- see the old comment on ExecProject.) A test case involving many levels of join of fairly wide tables (about 80 columns altogether) showed about 3x overall speedup, though simple queries will probably not be helped very much. I have also duplicated some code in heaptuple.c in order to provide versions of heap_formtuple and friends that use "bool" arrays to indicate null attributes, instead of the old convention of "char" arrays containing either 'n' or ' '. This provides a better match to the convention used by ExecEvalExpr. While I have not made a concerted effort to get rid of uses of the old routines, I think they should be deprecated and eventually removed.
* ALTER TABLE ADD COLUMN exhibits a significant memory leak when adding aNeil Conway2005-02-09
| | | | | | | | | | | | | | | | | | | | 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.
* Change heap_modifytuple() to require a TupleDesc rather than aNeil Conway2005-01-27
| | | | | Relation. Patch from Alvaro Herrera, minor editorializing by Neil Conway.
* Generalize TRUNCATE to support truncating multiple tables in oneTom Lane2005-01-27
| | | | | | | | command. This is useful because we can allow truncation of tables referenced by foreign keys, so long as the referencing table is truncated in the same command. Alvaro Herrera
* Fix ALTER TABLE ADD COLUMN so that constraints of domain types areTom Lane2005-01-24
| | | | | enforced properly when there is no explicit default value for the new column. Per report from Craig Perras.
* Phase 1 of fix for 'SMgrRelation hashtable corrupted' problem. ThisTom Lane2005-01-10
| | | | | | 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.
* Tag appropriate files for rc3PostgreSQL Daemon2004-12-31
| | | | | | | | 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 ...
* Prevent a backend crash when processing CREATE TABLE commands withNeil Conway2004-11-16
| | | | | | | | 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.
* Create 'default_tablespace' GUC variable that supplies a TABLESPACETom Lane2004-11-05
| | | | | | | | | | 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.
* I found a corner case in which it is possible for RI_FKey_check's callTom Lane2004-10-30
| | | | | | | | | | | | | | 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.
* In ALTER COLUMN TYPE, strip any implicit coercion operations appearingTom Lane2004-10-22
| | | | | | 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.
* Disallow referential integrity actions from being deferred; only theTom Lane2004-10-21
| | | | | | | | 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.
* Give a more user-friendly error message in case where a table is createdTom Lane2004-10-16
| | | | in a schema whose default tablespace has been dropped.
* Message style revisionsPeter Eisentraut2004-10-12
|
* Fix ALTER TABLE OWNER to adjust the ownership of dependent sequences,Tom Lane2004-09-23
| | | | not only indexes. Alvaro Herrera, with some kibitzing by Tom Lane.
* Restructure subtransaction handling to reduce resource consumption,Tom Lane2004-09-16
| | | | | | | | | | | | | | | | | 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.
* needs_toast_table() should ignore dropped columns.Tom Lane2004-08-31
|
* copy_relation_data was mistakenly assuming that the source relationTom Lane2004-08-31
| | | | | would always be already open at the smgr level. Per bug report from Fabien Coelho.
* Pgindent run for 8.0.Bruce Momjian2004-08-29
|
* Update copyright to 2004.Bruce Momjian2004-08-29
|
* Rearrange order of operations in heap_drop_with_catalog and index_dropTom Lane2004-08-28
| | | | | | | | | | so that we close and flush the doomed relation's relcache entry before we start to delete the underlying catalog rows, rather than afterwards. For awhile yesterday I thought that an unexpected relcache entry rebuild partway through this sequence might explain the infrequent parallel regression failures we were chasing. It doesn't, mainly because there's no CommandCounterIncrement in the sequence and so the deletions aren't "really" done yet. But it sure seems like trouble waiting to happen.
* Dept. of further reflection: I looked around to see if any other callersTom Lane2004-08-15
| | | | | | | | | | | | of XLogInsert had the same sort of checkpoint interlock problem as RecordTransactionCommit, and indeed I found some. Btree index build and ALTER TABLE SET TABLESPACE write data outside the friendly confines of the buffer manager, and therefore they have to take their own responsibility for checkpoint interlock. The easiest solution seems to be to force smgrimmedsync at the end of the index build or table copy, even when the operation is being WAL-logged. This is sufficient since the new index or table will be of interest to no one if we don't get as far as committing the current transaction.
* Change order of operations in ALTER TABLE SET TABLESPACE so that weTom Lane2004-08-13
| | | | | | don't hold an open file reference to the original table at the end. This is a good thing in any case, particularly so on Windows which cannot drop the table file otherwise.
* Fix silly thinko in ALTER COLUMN TYPE. Check for finding expectedTom Lane2004-08-04
| | | | | | | dependency was looking at wrong columns and so would always fail. Was not exposed by regression tests because we are only testing cases involving built-in (pinned) types and so no actual dependency entry exists to be removed.
* Cause ALTER OWNER commands to update the object's ACL, replacing referencesTom Lane2004-08-01
| | | | | | to the old owner with the new owner. This is not necessarily right, but it's sure a lot more likely to be what the user wants than doing nothing. Christopher Kings-Lynne, some rework by Tom Lane.
* Invent WAL timelines, as per recent discussion, to make point-in-timeTom Lane2004-07-21
| | | | | | | | recovery more manageable. Also, undo recent change to add FILE_HEADER and WASTED_SPACE records to XLOG; instead make the XLOG page header variable-size with extra fields in the first page of an XLOG file. This should fix the boundary-case bugs observed by Mark Kirkwood. initdb forced due to change of XLOG representation.
* XLOG file archiving and point-in-time recovery. There are still someTom Lane2004-07-19
| | | | | | loose ends and a glaring lack of documentation, but it basically works. Simon Riggs with some editorialization by Tom Lane.
* When renaming a column that participates in a foreign key, we mustTom Lane2004-07-17
| | | | | | 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.
* ALTER TABLE SET TABLESPACE. Gavin Sherry, some rework by Tom Lane.Tom Lane2004-07-11
|
* Nested transactions. There is still much left to do, especially on theTom Lane2004-07-01
| | | | | | | performance front, but with feature freeze upon us I think it's time to drive a stake in the ground and say that this will be in 7.5. Alvaro Herrera, with some help from Tom Lane.
* Support renaming of tablespaces, and changing the owners ofTom Lane2004-06-25
| | | | | | | | aggregates, conversions, functions, operators, operator classes, schemas, types, and tablespaces. Fold the existing implementations of alter domain owner and alter database owner in with these. Christopher Kings-Lynne
* Tablespaces. Alternate database locations are dead, long live tablespaces.Tom Lane2004-06-18
| | | | | | | | | There are various things left to do: contrib dbsize and oid2name modules need work, and so does the documentation. Also someone should think about COMMENT ON TABLESPACE and maybe RENAME TABLESPACE. Also initlocation is dead, it just doesn't know it yet. Gavin Sherry and Tom Lane.
* Make ALTER TABLE ADD SERIAL work reasonably in inheritance cases, too.Tom Lane2004-06-10
|
* Fix oversight in recent ALTER TABLE improvements. We now supportTom Lane2004-06-10
| | | | | | ALTER TABLE tab ADD COLUMN col SERIAL, but we forgot to install the dependency between the column and the sequence, so the sequence would not go away if you dropped the table later.
* Clean up generation of default names for constraints, indexes, and serialTom Lane2004-06-10
| | | | | | | | sequences, as per recent discussion. All these names are now of the form table_column_type, with digits added if needed to make them unique. Default constraint names are chosen to be unique across their whole schema, not just within the parent object, so as to be more SQL-spec-compatible and make the information schema views more useful.
* Allow use of table rowtypes directly as column types of other tables.Tom Lane2004-06-06
| | | | | | | | Instead of prohibiting that, put code into ALTER TABLE to reject ALTERs that would affect other tables' columns. Eventually we will probably want to extend ALTER TABLE to actually do something useful here, but in the meantime it seems wrong to forbid the feature completely just because ALTER isn't fully baked.
* Tweak palloc/repalloc to allow zero bytes to be requested, as per recentTom Lane2004-06-05
| | | | | proposal. Eliminate several dozen now-unnecessary hacks to avoid palloc(0). (It's likely there are more that I didn't find.)