diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-05-05 04:48:48 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-05-05 04:48:48 +0000 |
| commit | 077db40fa1f3ef93a60d995cc5b2666474f81302 (patch) | |
| tree | 911e14b79a368b10ad9fc267fa69f299e86b15f9 /src/include/catalog/heap.h | |
| parent | 3e3cb0a14a608bb058407b6349c3c9e2d09e13b8 (diff) | |
| download | postgresql-077db40fa1f3ef93a60d995cc5b2666474f81302.tar.gz | |
ALTER TABLE rewrite. New cool stuff:
* ALTER ... ADD COLUMN with defaults and NOT NULL constraints works per SQL
spec. A default is implemented by rewriting the table with the new value
stored in each row.
* ALTER COLUMN TYPE. You can change a column's datatype to anything you
want, so long as you can specify how to convert the old value. Rewrites
the table. (Possible future improvement: optimize no-op conversions such
as varchar(N) to varchar(N+1).)
* Multiple ALTER actions in a single ALTER TABLE command. You can perform
any number of column additions, type changes, and constraint additions with
only one pass over the table contents.
Basic documentation provided in ALTER TABLE ref page, but some more docs
work is needed.
Original patch from Rod Taylor, additional work from Tom Lane.
Diffstat (limited to 'src/include/catalog/heap.h')
| -rw-r--r-- | src/include/catalog/heap.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index f635ef1bd0..2913d53e52 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.65 2004/03/23 19:35:17 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.66 2004/05/05 04:48:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -27,6 +27,14 @@ typedef struct RawColumnDefault * tree) */ } RawColumnDefault; +typedef struct CookedConstraint +{ + ConstrType contype; /* CONSTR_DEFAULT or CONSTR_CHECK */ + char *name; /* name, or NULL if none */ + AttrNumber attnum; /* which attr (only for DEFAULT) */ + Node *expr; /* transformed default or check expr */ +} CookedConstraint; + extern Relation heap_create(const char *relname, Oid relnamespace, TupleDesc tupDesc, @@ -52,10 +60,12 @@ extern void heap_truncate(Oid rid); extern void heap_truncate_check_FKs(Relation rel); -extern void AddRelationRawConstraints(Relation rel, +extern List *AddRelationRawConstraints(Relation rel, List *rawColDefaults, List *rawConstraints); +extern void StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin); + extern Node *cookDefault(ParseState *pstate, Node *raw_default, Oid atttypid, |
