aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2000-01-16 20:05:00 +0000
committerPeter Eisentraut <peter_e@gmx.net>2000-01-16 20:05:00 +0000
commit759fba48734fdb93094ed6fe6b0d0c4d533fd0ca (patch)
tree504e54982096b18273f254a553bddbbcf16ae5f0 /src/backend
parenta4e1304ed1700c9831fdacc908fa0461ef0f5151 (diff)
downloadpostgresql-759fba48734fdb93094ed6fe6b0d0c4d533fd0ca.tar.gz
postgresql-759fba48734fdb93094ed6fe6b0d0c4d533fd0ca.zip
Included all yacc and lex files into the distribution.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/bootstrap/Makefile4
-rw-r--r--src/backend/catalog/aclchk.c6
-rw-r--r--src/backend/catalog/catalog.c8
-rw-r--r--src/backend/commands/command.c256
-rw-r--r--src/backend/parser/gram.y105
-rw-r--r--src/backend/tcop/utility.c58
6 files changed, 357 insertions, 80 deletions
diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile
index 32af98b22a1..3e47413d798 100644
--- a/src/backend/bootstrap/Makefile
+++ b/src/backend/bootstrap/Makefile
@@ -4,7 +4,7 @@
# Makefile for the bootstrap module
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.19 1999/12/16 16:52:46 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.20 2000/01/16 20:04:53 petere Exp $
#
#
# We must build bootparse.c and bootscanner.c with yacc and lex and sed,
@@ -68,7 +68,7 @@ bootscanner.c: bootscanner.l
rm -f lex.yy.c sedfile
clean:
- rm -f SUBSYS.o $(OBJS) bootparse.c bootstrap_tokens.h bootscanner.c
+ rm -f SUBSYS.o $(OBJS)
# And the garbage that might have been left behind by partial build:
rm -f y.tab.h y.tab.c y.output lex.yy.c
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index b9485532834..09aa138cf7c 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.34 2000/01/15 02:59:28 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.35 2000/01/16 20:04:54 petere Exp $
*
* NOTES
* See acl.h.
@@ -444,8 +444,8 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
}
int32
-pg_ownercheck(char *usename,
- char *value,
+pg_ownercheck(const char *usename,
+ const char *value,
int cacheid)
{
HeapTuple tuple;
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 1523786aa99..20256babded 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.27 2000/01/15 02:59:28 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.28 2000/01/16 20:04:54 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,7 +26,7 @@
* Perhaps this should be in-line code in relopen().
*/
char *
-relpath(char *relname)
+relpath(const char *relname)
{
char *path;
size_t bufsize = 0;
@@ -52,7 +52,7 @@ relpath(char *relname)
* XXX this is way bogus. -- pma
*/
bool
-IsSystemRelationName(char *relname)
+IsSystemRelationName(const char *relname)
{
if (relname[0] && relname[1] && relname[2])
return (relname[0] == 'p' &&
@@ -67,7 +67,7 @@ IsSystemRelationName(char *relname)
* True iff name is the name of a shared system catalog relation.
*/
bool
-IsSharedSystemRelationName(char *relname)
+IsSharedSystemRelationName(const char *relname)
{
int i;
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index 1874e0e2369..93322d7a7f7 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.62 1999/12/20 10:40:41 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.63 2000/01/16 20:04:55 petere Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -23,13 +23,16 @@
#include "postgres.h"
#include "access/heapam.h"
+#include "access/skey.h"
#include "catalog/catalog.h"
#include "catalog/catname.h"
#include "catalog/indexing.h"
+#include "catalog/pg_attrdef.h"
#include "catalog/pg_type.h"
#include "commands/command.h"
#include "executor/execdefs.h"
#include "executor/executor.h"
+#include "catalog/heap.h"
#include "miscadmin.h"
#include "optimizer/prep.h"
#include "utils/acl.h"
@@ -37,6 +40,7 @@
#include "utils/syscache.h"
#include "utils/temprel.h"
+
/* ----------------
* PortalExecutorHeapMemory stuff
*
@@ -246,7 +250,8 @@ PerformPortalClose(char *name, CommandDest dest)
}
/* ----------------
- * PerformAddAttribute
+ * AlterTableAddColumn
+ * (formerly known as PerformAddAttribute)
*
* adds an additional attribute to a relation
*
@@ -276,8 +281,7 @@ PerformPortalClose(char *name, CommandDest dest)
* ----------------
*/
void
-PerformAddAttribute(char *relationName,
- char *userName,
+AlterTableAddColumn(const char *relationName,
bool inherits,
ColumnDef *colDef)
{
@@ -295,6 +299,7 @@ PerformAddAttribute(char *relationName,
Relation idescs[Num_pg_attr_indices];
Relation ridescs[Num_pg_class_indices];
bool hasindex;
+ List *rawDefaults = NIL;
/*
* permissions checking. this would normally be done in utility.c,
@@ -303,19 +308,18 @@ PerformAddAttribute(char *relationName,
* normally, only the owner of a class can change its schema.
*/
if (!allowSystemTableMods && IsSystemRelationName(relationName))
- elog(ERROR, "PerformAddAttribute: class \"%s\" is a system catalog",
+ elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
relationName);
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relationName, RELNAME))
- elog(ERROR, "PerformAddAttribute: you do not own class \"%s\"",
- relationName);
+ if (!pg_ownercheck(UserName, relationName, RELNAME))
+ elog(ERROR, "ALTER TABLE: permission denied");
#endif
/*
* Grab an exclusive lock on the target table, which we will NOT release
* until end of transaction.
*/
- rel = heap_openr(relationName, AccessExclusiveLock);
+ rel = heap_openr((char *)relationName, AccessExclusiveLock);
myrelid = RelationGetRelid(rel);
heap_close(rel, NoLock); /* close rel but keep lock! */
@@ -324,8 +328,10 @@ PerformAddAttribute(char *relationName,
*/
if (colDef->is_not_null)
elog(ERROR, "Can't add a NOT NULL attribute to an existing relation");
+
if (colDef->raw_default || colDef->cooked_default)
- elog(ERROR, "ADD ATTRIBUTE: DEFAULT not yet implemented");
+ elog(ERROR, "Adding columns with defaults is not implemented.");
+
/*
* if the first element in the 'schema' list is a "*" then we are
@@ -358,8 +364,8 @@ PerformAddAttribute(char *relationName,
if (childrelid == myrelid)
continue;
rel = heap_open(childrelid, AccessExclusiveLock);
- PerformAddAttribute(RelationGetRelationName(rel),
- userName, false, colDef);
+ AlterTableAddColumn(RelationGetRelationName(rel),
+ false, colDef);
heap_close(rel, AccessExclusiveLock);
}
}
@@ -372,7 +378,7 @@ PerformAddAttribute(char *relationName,
0, 0, 0);
if (!HeapTupleIsValid(reltup))
- elog(ERROR, "PerformAddAttribute: relation \"%s\" not found",
+ elog(ERROR, "ALTER TABLE: relation \"%s\" not found",
relationName);
/*
@@ -380,14 +386,14 @@ PerformAddAttribute(char *relationName,
*/
if (((Form_pg_class) GETSTRUCT(reltup))->relkind == RELKIND_INDEX)
{
- elog(ERROR, "PerformAddAttribute: index relation \"%s\" not changed",
+ elog(ERROR, "ALTER TABLE: index relation \"%s\" not changed",
relationName);
}
minattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts;
maxatts = minattnum + 1;
if (maxatts > MaxHeapAttributeNumber)
- elog(ERROR, "PerformAddAttribute: relations limited to %d attributes",
+ elog(ERROR, "ALTER TABLE: relations limited to %d columns",
MaxHeapAttributeNumber);
attrdesc = heap_openr(AttributeRelationName, RowExclusiveLock);
@@ -421,7 +427,7 @@ PerformAddAttribute(char *relationName,
0, 0);
if (HeapTupleIsValid(tup))
- elog(ERROR, "PerformAddAttribute: attribute \"%s\" already exists in class \"%s\"",
+ elog(ERROR, "ALTER TABLE: column name \"%s\" already exists in relation \"%s\"",
colDef->colname, relationName);
/*
@@ -444,7 +450,7 @@ PerformAddAttribute(char *relationName,
tform = (Form_pg_type) GETSTRUCT(typeTuple);
if (!HeapTupleIsValid(typeTuple))
- elog(ERROR, "Add: type \"%s\" nonexistent", typename);
+ elog(ERROR, "ALTER TABLE: type \"%s\" does not exist", typename);
namestrcpy(&(attribute->attname), colDef->colname);
attribute->atttypid = typeTuple->t_data->t_oid;
attribute->attlen = tform->typlen;
@@ -483,9 +489,223 @@ PerformAddAttribute(char *relationName,
CatalogCloseIndices(Num_pg_class_indices, ridescs);
heap_freetuple(reltup);
- heap_close(rel, RowExclusiveLock);
+
+ heap_close(rel, NoLock);
+}
+
+
+
+static void drop_default(Oid relid, int16 attnum);
+
+
+/*
+ * ALTER TABLE ALTER COLUMN SET/DROP DEFAULT
+ */
+void
+AlterTableAlterColumn(const char *relationName,
+ bool inh, const char *colName,
+ Node *newDefault)
+{
+ Relation rel;
+ HeapTuple tuple;
+ int16 attnum;
+ Oid myrelid;
+
+ if (!allowSystemTableMods && IsSystemRelationName(relationName))
+ elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
+ relationName);
+#ifndef NO_SECURITY
+ if (!pg_ownercheck(UserName, relationName, RELNAME))
+ elog(ERROR, "ALTER TABLE: permission denied");
+#endif
+
+ /* XXX should heap_openr take const char * ? */
+ rel = heap_openr((char *)relationName, AccessExclusiveLock);
+ myrelid = RelationGetRelid(rel);
+ heap_close(rel, NoLock);
+
+ /*
+ * Propagate to children if desired
+ */
+ if (inh)
+ {
+ List *child,
+ *children;
+
+ /* this routine is actually in the planner */
+ children = find_all_inheritors(myrelid);
+
+ /*
+ * find_all_inheritors does the recursive search of the
+ * inheritance hierarchy, so all we have to do is process all
+ * of the relids in the list that it returns.
+ */
+ foreach(child, children)
+ {
+ Oid childrelid = lfirsti(child);
+
+ if (childrelid == myrelid)
+ continue;
+ rel = heap_open(childrelid, AccessExclusiveLock);
+ AlterTableAlterColumn(RelationGetRelationName(rel),
+ false, colName, newDefault);
+ heap_close(rel, AccessExclusiveLock);
+ }
+ }
+
+ /* -= now do the thing on this relation =- */
+
+ /* reopen the business */
+ rel = heap_openr((char *)relationName, AccessExclusiveLock);
+
+ /*
+ * get the number of the attribute
+ */
+ tuple = SearchSysCacheTuple(ATTNAME,
+ ObjectIdGetDatum(myrelid),
+ NameGetDatum(namein((char *)colName)),
+ 0, 0);
+
+ if (!HeapTupleIsValid(tuple))
+ {
+ heap_close(rel, AccessExclusiveLock);
+ elog(ERROR, "ALTER TABLE: relation \"%s\" has no column \"%s\"",
+ relationName, colName);
+ }
+
+ attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
+
+ if (newDefault) /* SET DEFAULT */
+ {
+ List* rawDefaults = NIL;
+ RawColumnDefault *rawEnt;
+
+ /* Get rid of the old one first */
+ drop_default(myrelid, attnum);
+
+ rawEnt = (RawColumnDefault *) palloc(sizeof(RawColumnDefault));
+ rawEnt->attnum = attnum;
+ rawEnt->raw_default = newDefault;
+ rawDefaults = lappend(rawDefaults, rawEnt);
+
+ /*
+ * This function is intended for CREATE TABLE,
+ * so it processes a _list_ of defaults, but we just do one.
+ */
+ AddRelationRawConstraints(rel, rawDefaults, NIL);
+ }
+
+ else /* DROP DEFAULT */
+ {
+ Relation attr_rel;
+ ScanKeyData scankeys[3];
+ HeapScanDesc scan;
+ HeapTuple tuple;
+
+ attr_rel = heap_openr(AttributeRelationName, AccessExclusiveLock);
+ ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attribute_attrelid, F_OIDEQ,
+ ObjectIdGetDatum(myrelid));
+ ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attribute_attnum, F_INT2EQ,
+ Int16GetDatum(attnum));
+ ScanKeyEntryInitialize(&scankeys[2], 0x0, Anum_pg_attribute_atthasdef, F_BOOLEQ,
+ TRUE);
+
+ scan = heap_beginscan(attr_rel, false, SnapshotNow, 3, scankeys);
+ AssertState(scan!=NULL);
+
+ if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+ {
+ HeapTuple newtuple;
+ Relation irelations[Num_pg_attr_indices];
+
+ /* update to false */
+ newtuple = heap_copytuple(tuple);
+ ((Form_pg_attribute) GETSTRUCT(newtuple))->atthasdef = FALSE;
+ heap_update(attr_rel, &tuple->t_self, newtuple, NULL);
+
+ /* keep the system catalog indices current */
+ CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
+ CatalogIndexInsert(irelations, Num_pg_attr_indices, attr_rel, newtuple);
+ CatalogCloseIndices(Num_pg_class_indices, irelations);
+
+ /* get rid of actual default definition */
+ drop_default(myrelid, attnum);
+ }
+ else
+ elog(NOTICE, "ALTER TABLE: there was no default on column \"%s\" of relation \"%s\"",
+ colName, relationName);
+ heap_endscan(scan);
+ heap_close(attr_rel, NoLock);
+ }
+
+ heap_close(rel, NoLock);
+}
+
+
+
+static void
+drop_default(Oid relid, int16 attnum)
+{
+ ScanKeyData scankeys[2];
+ HeapScanDesc scan;
+ Relation attrdef_rel;
+ HeapTuple tuple;
+
+ attrdef_rel = heap_openr(AttrDefaultRelationName, AccessExclusiveLock);
+ ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attrdef_adrelid, F_OIDEQ,
+ ObjectIdGetDatum(relid));
+ ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attrdef_adnum, F_INT2EQ,
+ Int16GetDatum(attnum));
+
+ scan = heap_beginscan(attrdef_rel, false, SnapshotNow, 2, scankeys);
+ AssertState(scan!=NULL);
+
+ if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
+ heap_delete(attrdef_rel, &tuple->t_self, NULL);
+
+ heap_endscan(scan);
+
+ heap_close(attrdef_rel, NoLock);
+}
+
+
+
+/*
+ * ALTER TABLE DROP COLUMN
+ */
+void
+AlterTableDropColumn(const char *relationName,
+ bool inh, const char *colName,
+ int behavior)
+{
+ elog(NOTICE, "ALTER TABLE / DROP COLUMN is not implemented");
}
+
+
+void
+AlterTableAddConstraint(const char *relationName,
+ bool inh, Node *newConstraint)
+{
+ elog(NOTICE, "ALTER TABLE / ADD CONSTRAINT is not implemented");
+}
+
+
+
+void AlterTableDropConstraint(const char *relationName,
+ bool inh, const char *constrName,
+ int behavior)
+{
+ elog(NOTICE, "ALTER TABLE / DROP CONSTRAINT is not implemented");
+}
+
+
+
+/*
+ *
+ * LOCK TABLE
+ *
+ */
void
LockTableCommand(LockStmt *lockstmt)
{
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index b7e3b6f47a9..a3a01d510f0 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.126 2000/01/15 02:59:32 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.127 2000/01/16 20:04:55 petere Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -114,7 +114,7 @@ static Node *doNegate(Node *n);
}
%type <node> stmt,
- AddAttrStmt, ClosePortalStmt,
+ AlterTableStmt, ClosePortalStmt,
CopyStmt, CreateStmt, CreateAsStmt, CreateSeqStmt, DefineStmt, DropStmt,
TruncateStmt, CommentStmt,
ExtendStmt, FetchStmt, GrantStmt, CreateTrigStmt, DropTrigStmt,
@@ -130,6 +130,9 @@ static Node *doNegate(Node *n);
RuleActionStmtOrEmpty, ConstraintsSetStmt,
CreateGroupStmt, AlterGroupStmt, DropGroupStmt
+%type <node> alter_column_action
+%type <ival> drop_behavior
+
%type <str> createdb_opt_location
%type <ival> createdb_opt_encoding
@@ -210,7 +213,7 @@ static Node *doNegate(Node *n);
%type <astmt> insert_rest
%type <node> OptTableElement, ConstraintElem
-%type <node> columnDef, alter_clause
+%type <node> columnDef
%type <defelt> def_elem
%type <node> def_arg, columnElem, where_clause,
a_expr, a_expr_or_null, b_expr, com_expr, AexprConst,
@@ -391,7 +394,7 @@ stmtmulti: stmtmulti ';' stmt
}
;
-stmt : AddAttrStmt
+stmt : AlterTableStmt
| AlterGroupStmt
| AlterUserStmt
| ClosePortalStmt
@@ -797,40 +800,74 @@ constraints_set_mode: DEFERRED
/*****************************************************************************
*
- * QUERY :
- * addattr ( attr1 = type1 .. attrn = typen ) to <relname> [*]
+ * ALTER TABLE variations
*
*****************************************************************************/
-AddAttrStmt: ALTER TABLE relation_name opt_inh_star alter_clause
- {
- AddAttrStmt *n = makeNode(AddAttrStmt);
- n->relname = $3;
- n->inh = $4;
- n->colDef = $5;
- $$ = (Node *)n;
- }
- ;
+AlterTableStmt:
+/* ALTER TABLE <name> ADD [COLUMN] <coldef> */
+ ALTER TABLE relation_name opt_inh_star ADD opt_column columnDef
+ {
+ AlterTableStmt *n = makeNode(AlterTableStmt);
+ n->subtype = 'A';
+ n->relname = $3;
+ n->inh = $4;
+ n->def = $7;
+ $$ = (Node *)n;
+ }
+/* ALTER TABLE <name> ALTER [COLUMN] <colname> {SET DEFAULT <expr>|DROP DEFAULT} */
+ | ALTER TABLE relation_name opt_inh_star ALTER opt_column ColId alter_column_action
+ {
+ AlterTableStmt *n = makeNode(AlterTableStmt);
+ n->subtype = 'T';
+ n->relname = $3;
+ n->inh = $4;
+ n->name = $7;
+ n->def = $8;
+ $$ = (Node *)n;
+ }
+/* ALTER TABLE <name> DROP [COLUMN] <name> {RESTRICT|CASCADE} */
+ | ALTER TABLE relation_name opt_inh_star DROP opt_column ColId drop_behavior
+ {
+ AlterTableStmt *n = makeNode(AlterTableStmt);
+ n->subtype = 'D';
+ n->relname = $3;
+ n->inh = $4;
+ n->name = $7;
+ n->behavior = $8;
+ $$ = (Node *)n;
+ }
+/* ALTER TABLE <name> ADD CONSTRAINT ... */
+ | ALTER TABLE relation_name opt_inh_star ADD TableConstraint
+ {
+ AlterTableStmt *n = makeNode(AlterTableStmt);
+ n->subtype = 'A';
+ n->relname = $3;
+ n->inh = $4;
+ n->def = $6;
+ $$ = (Node *)n;
+ }
+/* ALTER TABLE <name> DROP CONSTRAINT <name> {RESTRICT|CASCADE} */
+ | ALTER TABLE relation_name opt_inh_star DROP CONSTRAINT name drop_behavior
+ {
+ AlterTableStmt *n = makeNode(AlterTableStmt);
+ n->relname = $3;
+ n->inh = $4;
+ n->name = $7;
+ n->behavior = $8;
+ $$ = (Node *)n;
+ }
+ ;
+
+alter_column_action:
+ SET DEFAULT a_expr_or_null { $$ = $3; }
+ | DROP DEFAULT { $$ = NULL; }
+ ;
+
+drop_behavior: CASCADE { $$ = CASCADE; }
+ | RESTRICT { $$ = RESTRICT; }
+ ;
-alter_clause: ADD opt_column columnDef
- {
- $$ = $3;
- }
- | ADD '(' OptTableElementList ')'
- {
- if (length($3) != 1)
- elog(ERROR,"ALTER TABLE/ADD() allows one column only");
- $$ = (Node *) lfirst($3);
- }
- | DROP opt_column ColId
- { elog(ERROR,"ALTER TABLE/DROP COLUMN not yet implemented"); }
- | ALTER opt_column ColId SET DEFAULT a_expr
- { elog(ERROR,"ALTER TABLE/ALTER COLUMN/SET DEFAULT not yet implemented"); }
- | ALTER opt_column ColId DROP DEFAULT
- { elog(ERROR,"ALTER TABLE/ALTER COLUMN/DROP DEFAULT not yet implemented"); }
- | ADD ConstraintElem
- { elog(ERROR,"ALTER TABLE/ADD CONSTRAINT not yet implemented"); }
- ;
/*****************************************************************************
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 250e30ef4b4..ead435b09cd 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.79 2000/01/15 18:30:30 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.80 2000/01/16 20:04:56 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -270,24 +270,6 @@ ProcessUtility(Node *parsetree,
}
break;
- case T_AddAttrStmt:
- {
- AddAttrStmt *stmt = (AddAttrStmt *) parsetree;
-
- PS_SET_STATUS(commandTag = "ADD");
- CHECK_IF_ABORTED();
-
- /*
- * owner checking done in PerformAddAttribute (now
- * recursive)
- */
- PerformAddAttribute(stmt->relname,
- userName,
- stmt->inh,
- (ColumnDef *) stmt->colDef);
- }
- break;
-
/*
* schema
*/
@@ -346,6 +328,44 @@ ProcessUtility(Node *parsetree,
}
break;
+ /* various Alter Table forms */
+
+ case T_AlterTableStmt:
+ {
+ AlterTableStmt *stmt = (AlterTableStmt *) parsetree;
+
+ PS_SET_STATUS(commandTag = "ALTER TABLE");
+ CHECK_IF_ABORTED();
+
+ /*
+ * Some or all of these functions are recursive to cover inherited things,
+ * so permission checks are done there.
+ */
+ switch(stmt->subtype)
+ {
+ case 'A': /* ADD COLUMN */
+ AlterTableAddColumn(stmt->relname, stmt->inh, (ColumnDef *) stmt->def);
+ break;
+ case 'T': /* ALTER COLUMN */
+ AlterTableAlterColumn(stmt->relname, stmt->inh, stmt->name, stmt->def);
+ break;
+ case 'D': /* ALTER DROP */
+ AlterTableDropColumn(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
+ break;
+ case 'C': /* ADD CONSTRAINT */
+ AlterTableAddConstraint(stmt->relname, stmt->inh, stmt->def);
+ break;
+ case 'X': /* DROP CONSTRAINT */
+ AlterTableDropConstraint(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
+ break;
+ default: /* oops */
+ elog(ERROR, "T_AlterTableStmt: unknown subtype");
+ break;
+ }
+ }
+ break;
+
+
case T_ChangeACLStmt:
{
ChangeACLStmt *stmt = (ChangeACLStmt *) parsetree;