aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/copyfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-05-05 04:48:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-05-05 04:48:48 +0000
commit077db40fa1f3ef93a60d995cc5b2666474f81302 (patch)
tree911e14b79a368b10ad9fc267fa69f299e86b15f9 /src/backend/nodes/copyfuncs.c
parent3e3cb0a14a608bb058407b6349c3c9e2d09e13b8 (diff)
downloadpostgresql-077db40fa1f3ef93a60d995cc5b2666474f81302.tar.gz
postgresql-077db40fa1f3ef93a60d995cc5b2666474f81302.zip
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/backend/nodes/copyfuncs.c')
-rw-r--r--src/backend/nodes/copyfuncs.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index c7d6193280e..1466be98cbb 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.279 2004/03/17 20:48:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.280 2004/05/05 04:48:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1674,10 +1674,21 @@ _copyAlterTableStmt(AlterTableStmt *from)
{
AlterTableStmt *newnode = makeNode(AlterTableStmt);
- COPY_SCALAR_FIELD(subtype);
COPY_NODE_FIELD(relation);
+ COPY_NODE_FIELD(cmds);
+
+ return newnode;
+}
+
+static AlterTableCmd *
+_copyAlterTableCmd(AlterTableCmd *from)
+{
+ AlterTableCmd *newnode = makeNode(AlterTableCmd);
+
+ COPY_SCALAR_FIELD(subtype);
COPY_STRING_FIELD(name);
COPY_NODE_FIELD(def);
+ COPY_NODE_FIELD(transform);
COPY_SCALAR_FIELD(behavior);
return newnode;
@@ -2773,6 +2784,9 @@ copyObject(void *from)
case T_AlterTableStmt:
retval = _copyAlterTableStmt(from);
break;
+ case T_AlterTableCmd:
+ retval = _copyAlterTableCmd(from);
+ break;
case T_AlterDomainStmt:
retval = _copyAlterDomainStmt(from);
break;