ALTER TABLE rewrite. New cool stuff:
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 5 May 2004 04:48:48 +0000 (04:48 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 5 May 2004 04:48:48 +0000 (04:48 +0000)
commit077db40fa1f3ef93a60d995cc5b2666474f81302
tree911e14b79a368b10ad9fc267fa69f299e86b15f9
parent3e3cb0a14a608bb058407b6349c3c9e2d09e13b8
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.
30 files changed:
doc/src/sgml/ref/alter_table.sgml
src/backend/bootstrap/bootparse.y
src/backend/catalog/dependency.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/commands/cluster.c
src/backend/commands/indexcmds.c
src/backend/commands/tablecmds.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/backend/tcop/utility.c
src/backend/utils/adt/ruleutils.c
src/include/catalog/dependency.h
src/include/catalog/heap.h
src/include/catalog/index.h
src/include/commands/cluster.h
src/include/commands/defrem.h
src/include/commands/tablecmds.h
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/include/parser/analyze.h
src/include/utils/builtins.h
src/test/regress/expected/alter_table.out
src/test/regress/expected/foreign_key.out
src/test/regress/expected/inherit.out
src/test/regress/sql/alter_table.sql
src/test/regress/sql/foreign_key.sql
src/test/regress/sql/inherit.sql