summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a3ec44a)
RESTRICT/CASCADE syntax to the DROP commands that need it, and propagates
the behavioral option through the parser to the routines that execute
drops. Doesn't do anything useful yet, but I figured I'd commit these
changes so I could get out of the parser area while working on the rest.
13 files changed:
- * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.75 2002/06/20 20:29:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.76 2002/07/01 15:27:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
/*
* RemoveIndex
* Deletes an index.
/*
* RemoveIndex
* Deletes an index.
- *
- * Exceptions:
- * BadArg if name is invalid.
- * "ERROR" if index nonexistent.
- * ...
-RemoveIndex(RangeVar *relation)
+RemoveIndex(RangeVar *relation, DropBehavior behavior)
{
Oid indOid;
HeapTuple tuple;
{
Oid indOid;
HeapTuple tuple;
- * $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.3 2002/04/27 03:45:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.4 2002/07/01 15:27:46 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
/*
* RemoveOperator
* Deletes an operator.
/*
* RemoveOperator
* Deletes an operator.
- *
- * Exceptions:
- * BadArg if name is invalid.
- * BadArg if type1 is invalid.
- * "ERROR" if operator nonexistent.
- * ...
-RemoveOperator(List *operatorName, /* operator name */
- TypeName *typeName1, /* left argument type name */
- TypeName *typeName2) /* right argument type name */
+RemoveOperator(RemoveOperStmt *stmt)
+ List *operatorName = stmt->opname;
+ TypeName *typeName1 = (TypeName *) lfirst(stmt->args);
+ TypeName *typeName2 = (TypeName *) lsecond(stmt->args);
Oid operOid;
Relation relation;
HeapTuple tup;
Oid operOid;
Relation relation;
HeapTuple tup;
- * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.17 2002/06/17 14:31:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.18 2002/07/01 15:27:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
#include "optimizer/clauses.h"
#include "optimizer/planmain.h"
#include "optimizer/prep.h"
#include "optimizer/clauses.h"
#include "optimizer/planmain.h"
#include "optimizer/prep.h"
-#include "parser/parse.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
#include "parser/parse_relation.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
#include "parser/parse_relation.h"
* themselves will be destroyed, too.
*/
void
* themselves will be destroyed, too.
*/
void
-RemoveRelation(const RangeVar *relation)
+RemoveRelation(const RangeVar *relation, DropBehavior behavior)
void
AlterTableDropColumn(Oid myrelid,
bool inh, const char *colName,
void
AlterTableDropColumn(Oid myrelid,
bool inh, const char *colName,
{
elog(ERROR, "ALTER TABLE / DROP COLUMN is not implemented");
}
{
elog(ERROR, "ALTER TABLE / DROP COLUMN is not implemented");
}
void
AlterTableDropConstraint(Oid myrelid,
bool inh, const char *constrName,
void
AlterTableDropConstraint(Oid myrelid,
bool inh, const char *constrName,
{
Relation rel;
int deleted;
{
Relation rel;
int deleted;
* We don't support CASCADE yet - in fact, RESTRICT doesn't work to
* the spec either!
*/
* We don't support CASCADE yet - in fact, RESTRICT doesn't work to
* the spec either!
*/
- if (behavior == CASCADE)
+ if (behavior == DROP_CASCADE)
elog(ERROR, "ALTER TABLE / DROP CONSTRAINT does not support the CASCADE keyword");
/*
elog(ERROR, "ALTER TABLE / DROP CONSTRAINT does not support the CASCADE keyword");
/*
- * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.3 2002/05/03 00:32:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.4 2002/07/01 15:27:48 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
#include "commands/comment.h"
#include "commands/defrem.h"
#include "miscadmin.h"
#include "commands/comment.h"
#include "commands/defrem.h"
#include "miscadmin.h"
-#include "parser/parse.h"
#include "parser/parse_func.h"
#include "parser/parse_type.h"
#include "utils/acl.h"
#include "parser/parse_func.h"
#include "parser/parse_type.h"
#include "utils/acl.h"
* only work on scalar types.
*/
void
* only work on scalar types.
*/
void
+RemoveType(List *names, DropBehavior behavior)
{
TypeName *typename;
Relation relation;
{
TypeName *typename;
Relation relation;
* Removes a domain.
*/
void
* Removes a domain.
*/
void
-RemoveDomain(List *names, int behavior)
+RemoveDomain(List *names, DropBehavior behavior)
{
TypeName *typename;
Relation relation;
{
TypeName *typename;
Relation relation;
char typtype;
/* CASCADE unsupported */
char typtype;
/* CASCADE unsupported */
- if (behavior == CASCADE)
+ if (behavior == DROP_CASCADE)
elog(ERROR, "DROP DOMAIN does not support the CASCADE keyword");
/* Make a TypeName so we can use standard type lookup machinery */
elog(ERROR, "DROP DOMAIN does not support the CASCADE keyword");
/* Make a TypeName so we can use standard type lookup machinery */
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: view.c,v 1.64 2002/06/20 20:29:27 momjian Exp $
+ * $Id: view.c,v 1.65 2002/07/01 15:27:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
DefineViewRules(view, viewParse);
}
DefineViewRules(view, viewParse);
}
-/*------------------------------------------------------------------
* RemoveView
*
* Remove a view given its name
* RemoveView
*
* Remove a view given its name
- *------------------------------------------------------------------
-RemoveView(const RangeVar *view)
+RemoveView(const RangeVar *view, DropBehavior behavior)
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.191 2002/06/20 20:29:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.192 2002/07/01 15:27:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
Node_Copy(from, newnode, aggname);
Node_Copy(from, newnode, aggtype);
Node_Copy(from, newnode, aggname);
Node_Copy(from, newnode, aggtype);
+ newnode->behavior = from->behavior;
Node_Copy(from, newnode, funcname);
Node_Copy(from, newnode, args);
Node_Copy(from, newnode, funcname);
Node_Copy(from, newnode, args);
+ newnode->behavior = from->behavior;
Node_Copy(from, newnode, opname);
Node_Copy(from, newnode, args);
Node_Copy(from, newnode, opname);
Node_Copy(from, newnode, args);
+ newnode->behavior = from->behavior;
if (from->property)
newnode->property = pstrdup(from->property);
newnode->removeType = from->removeType;
if (from->property)
newnode->property = pstrdup(from->property);
newnode->removeType = from->removeType;
+ newnode->behavior = from->behavior;
if (from->plname)
newnode->plname = pstrdup(from->plname);
if (from->plname)
newnode->plname = pstrdup(from->plname);
+ newnode->behavior = from->behavior;
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.138 2002/06/20 20:29:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.139 2002/07/01 15:27:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
return false;
if (!equal(a->aggtype, b->aggtype))
return false;
return false;
if (!equal(a->aggtype, b->aggtype))
return false;
+ if (a->behavior != b->behavior)
+ return false;
return false;
if (!equal(a->args, b->args))
return false;
return false;
if (!equal(a->args, b->args))
return false;
+ if (a->behavior != b->behavior)
+ return false;
return false;
if (!equal(a->args, b->args))
return false;
return false;
if (!equal(a->args, b->args))
return false;
+ if (a->behavior != b->behavior)
+ return false;
return false;
if (a->removeType != b->removeType)
return false;
return false;
if (a->removeType != b->removeType)
return false;
+ if (a->behavior != b->behavior)
+ return false;
{
if (!equalstr(a->plname, b->plname))
return false;
{
if (!equalstr(a->plname, b->plname))
return false;
+ if (a->behavior != b->behavior)
+ return false;
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.334 2002/06/22 02:04:45 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.335 2002/07/01 15:27:55 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
const char *keyword;
bool boolean;
JoinType jtype;
const char *keyword;
bool boolean;
JoinType jtype;
+ DropBehavior dbehavior;
List *list;
Node *node;
Value *value;
List *list;
Node *node;
Value *value;
simple_select
%type <node> alter_column_default
simple_select
%type <node> alter_column_default
-%type <ival> add_drop, drop_behavior, opt_drop_behavior
+%type <ival> add_drop
+
+%type <dbehavior> opt_drop_behavior
%type <list> createdb_opt_list, copy_opt_list
%type <defelt> createdb_opt_item, copy_opt_item
%type <list> createdb_opt_list, copy_opt_list
%type <defelt> createdb_opt_item, copy_opt_item
*
* Drop a postgresql DBMS user
*
*
* Drop a postgresql DBMS user
*
+ * XXX Ideally this would have CASCADE/RESTRICT options, but since a user
+ * might own objects in multiple databases, there is presently no way to
+ * implement either cascading or restricting. Caveat DBA.
*****************************************************************************/
DropUserStmt:
*****************************************************************************/
DropUserStmt:
*
* Drop a postgresql group
*
*
* Drop a postgresql group
*
+ * XXX see above notes about cascading DROP USER; groups have same problem.
*****************************************************************************/
DropGroupStmt:
*****************************************************************************/
DropGroupStmt:
+ DROP SCHEMA ColId opt_drop_behavior
{
elog(ERROR, "DROP SCHEMA not yet supported");
}
{
elog(ERROR, "DROP SCHEMA not yet supported");
}
n->def = (Node *) makeString($9);
$$ = (Node *)n;
}
n->def = (Node *) makeString($9);
$$ = (Node *)n;
}
- /* ALTER TABLE <relation> DROP [COLUMN] <colname> {RESTRICT|CASCADE} */
- | ALTER TABLE relation_expr DROP opt_column ColId drop_behavior
+ /* ALTER TABLE <relation> DROP [COLUMN] <colname> [RESTRICT|CASCADE] */
+ | ALTER TABLE relation_expr DROP opt_column ColId opt_drop_behavior
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'D';
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'D';
n->def = $5;
$$ = (Node *)n;
}
n->def = $5;
$$ = (Node *)n;
}
- /* ALTER TABLE <relation> DROP CONSTRAINT <name> {RESTRICT|CASCADE} */
- | ALTER TABLE relation_expr DROP CONSTRAINT name drop_behavior
+ /* ALTER TABLE <relation> DROP CONSTRAINT <name> [RESTRICT|CASCADE] */
+ | ALTER TABLE relation_expr DROP CONSTRAINT name opt_drop_behavior
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'X';
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'X';
| DROP DEFAULT { $$ = NULL; }
;
| DROP DEFAULT { $$ = NULL; }
;
-drop_behavior:
- CASCADE { $$ = CASCADE; }
- | RESTRICT { $$ = RESTRICT; }
- ;
-
- CASCADE { $$ = CASCADE; }
- | RESTRICT { $$ = RESTRICT; }
- | /* EMPTY */ { $$ = RESTRICT; /* default */ }
+ CASCADE { $$ = DROP_CASCADE; }
+ | RESTRICT { $$ = DROP_RESTRICT; }
+ | /* EMPTY */ { $$ = DROP_RESTRICT; /* default */ }
- DROP opt_procedural LANGUAGE ColId_or_Sconst
+ DROP opt_procedural LANGUAGE ColId_or_Sconst opt_drop_behavior
{
DropPLangStmt *n = makeNode(DropPLangStmt);
n->plname = $4;
{
DropPLangStmt *n = makeNode(DropPLangStmt);
n->plname = $4;
- DROP TRIGGER name ON qualified_name
+ DROP TRIGGER name ON qualified_name opt_drop_behavior
{
DropPropertyStmt *n = makeNode(DropPropertyStmt);
n->relation = $5;
n->property = $3;
{
DropPropertyStmt *n = makeNode(DropPropertyStmt);
n->relation = $5;
n->property = $3;
n->removeType = DROP_TRIGGER;
$$ = (Node *) n;
}
n->removeType = DROP_TRIGGER;
$$ = (Node *) n;
}
+ DROP ASSERTION name opt_drop_behavior
{
DropPropertyStmt *n = makeNode(DropPropertyStmt);
n->relation = NULL;
n->property = $3;
{
DropPropertyStmt *n = makeNode(DropPropertyStmt);
n->relation = NULL;
n->property = $3;
- n->removeType = DROP_TRIGGER;
+ n->behavior = $4;
+ n->removeType = DROP_TRIGGER; /* XXX */
elog(ERROR, "DROP ASSERTION is not yet supported");
$$ = (Node *) n;
}
elog(ERROR, "DROP ASSERTION is not yet supported");
$$ = (Node *) n;
}
- * DROP itemtype itemname [, itemname ...]
+ * DROP itemtype itemname [, itemname ...] [ RESTRICT | CASCADE ]
*
*****************************************************************************/
*
*****************************************************************************/
- * DROP FUNCTION funcname (arg1, arg2, ...)
- * DROP AGGREGATE aggname (aggtype)
- * DROP OPERATOR opname (leftoperand_typ rightoperand_typ)
+ * DROP FUNCTION funcname (arg1, arg2, ...) [ RESTRICT | CASCADE ]
+ * DROP AGGREGATE aggname (aggtype) [ RESTRICT | CASCADE ]
+ * DROP OPERATOR opname (leftoperand_typ, rightoperand_typ) [ RESTRICT | CASCADE ]
*
*****************************************************************************/
*
*****************************************************************************/
RemoveFuncStmt *n = makeNode(RemoveFuncStmt);
n->funcname = $3;
n->args = $4;
RemoveFuncStmt *n = makeNode(RemoveFuncStmt);
n->funcname = $3;
n->args = $4;
- if ($5 != RESTRICT)
- elog(ERROR, "DROP FUNCTION/CASCADE not supported");
$$ = (Node *)n;
}
| DROP CAST '(' func_type AS func_type ')' opt_drop_behavior
$$ = (Node *)n;
}
| DROP CAST '(' func_type AS func_type ')' opt_drop_behavior
RemoveFuncStmt *n = makeNode(RemoveFuncStmt);
n->funcname = $6->names;
n->args = makeList1($4);
RemoveFuncStmt *n = makeNode(RemoveFuncStmt);
n->funcname = $6->names;
n->args = makeList1($4);
- if ($8 != RESTRICT)
- elog(ERROR, "DROP CAST/CASCADE not supported");
$$ = (Node *)n;
}
;
RemoveAggrStmt:
$$ = (Node *)n;
}
;
RemoveAggrStmt:
- DROP AGGREGATE func_name '(' aggr_argtype ')'
+ DROP AGGREGATE func_name '(' aggr_argtype ')' opt_drop_behavior
{
RemoveAggrStmt *n = makeNode(RemoveAggrStmt);
n->aggname = $3;
n->aggtype = $5;
{
RemoveAggrStmt *n = makeNode(RemoveAggrStmt);
n->aggname = $3;
n->aggtype = $5;
- DROP OPERATOR any_operator '(' oper_argtypes ')'
+ DROP OPERATOR any_operator '(' oper_argtypes ')' opt_drop_behavior
{
RemoveOperStmt *n = makeNode(RemoveOperStmt);
n->opname = $3;
n->args = $5;
{
RemoveOperStmt *n = makeNode(RemoveOperStmt);
n->opname = $3;
n->args = $5;
- DROP RULE name ON qualified_name
+ DROP RULE name ON qualified_name opt_drop_behavior
{
DropPropertyStmt *n = makeNode(DropPropertyStmt);
n->relation = $5;
n->property = $3;
{
DropPropertyStmt *n = makeNode(DropPropertyStmt);
n->relation = $5;
n->property = $3;
n->removeType = DROP_RULE;
$$ = (Node *) n;
}
n->removeType = DROP_RULE;
$$ = (Node *) n;
}
+ * This is implicitly CASCADE, no need for drop behavior
*****************************************************************************/
DropdbStmt: DROP DATABASE database_name
*****************************************************************************/
DropdbStmt: DROP DATABASE database_name
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.159 2002/06/20 20:29:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.160 2002/07/01 15:27:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
case DROP_TABLE:
rel = makeRangeVarFromNameList(names);
CheckDropPermissions(rel, RELKIND_RELATION);
case DROP_TABLE:
rel = makeRangeVarFromNameList(names);
CheckDropPermissions(rel, RELKIND_RELATION);
+ RemoveRelation(rel, stmt->behavior);
break;
case DROP_SEQUENCE:
rel = makeRangeVarFromNameList(names);
CheckDropPermissions(rel, RELKIND_SEQUENCE);
break;
case DROP_SEQUENCE:
rel = makeRangeVarFromNameList(names);
CheckDropPermissions(rel, RELKIND_SEQUENCE);
+ RemoveRelation(rel, stmt->behavior);
break;
case DROP_VIEW:
rel = makeRangeVarFromNameList(names);
CheckDropPermissions(rel, RELKIND_VIEW);
break;
case DROP_VIEW:
rel = makeRangeVarFromNameList(names);
CheckDropPermissions(rel, RELKIND_VIEW);
+ RemoveView(rel, stmt->behavior);
break;
case DROP_INDEX:
rel = makeRangeVarFromNameList(names);
CheckDropPermissions(rel, RELKIND_INDEX);
break;
case DROP_INDEX:
rel = makeRangeVarFromNameList(names);
CheckDropPermissions(rel, RELKIND_INDEX);
+ RemoveIndex(rel, stmt->behavior);
break;
case DROP_TYPE:
/* RemoveType does its own permissions checks */
break;
case DROP_TYPE:
/* RemoveType does its own permissions checks */
+ RemoveType(names, stmt->behavior);
break;
case T_RemoveOperStmt:
break;
case T_RemoveOperStmt:
- {
- RemoveOperStmt *stmt = (RemoveOperStmt *) parsetree;
- TypeName *typenode1 = (TypeName *) lfirst(stmt->args);
- TypeName *typenode2 = (TypeName *) lsecond(stmt->args);
-
- RemoveOperator(stmt->opname, typenode1, typenode2);
- }
+ RemoveOperator((RemoveOperStmt *) parsetree);
break;
case T_CreatedbStmt:
break;
case T_CreatedbStmt:
- {
- CreatedbStmt *stmt = (CreatedbStmt *) parsetree;
- createdb(stmt);
- }
+ createdb((CreatedbStmt *) parsetree);
break;
case T_AlterDatabaseSetStmt:
break;
case T_AlterDatabaseSetStmt:
- AlterDatabaseSet((AlterDatabaseSetStmt *)parsetree);
+ AlterDatabaseSet((AlterDatabaseSetStmt *) parsetree);
break;
case T_DropdbStmt:
break;
case T_DropdbStmt:
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: defrem.h,v 1.39 2002/06/20 20:29:49 momjian Exp $
+ * $Id: defrem.h,v 1.40 2002/07/01 15:27:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
bool primary,
Expr *predicate,
List *rangetable);
bool primary,
Expr *predicate,
List *rangetable);
-extern void RemoveIndex(RangeVar *relation);
+extern void RemoveIndex(RangeVar *relation, DropBehavior behavior);
extern void ReindexIndex(RangeVar *indexRelation, bool force);
extern void ReindexTable(RangeVar *relation, bool force);
extern void ReindexDatabase(const char *databaseName, bool force, bool all);
extern void ReindexIndex(RangeVar *indexRelation, bool force);
extern void ReindexTable(RangeVar *relation, bool force);
extern void ReindexDatabase(const char *databaseName, bool force, bool all);
extern void RemoveFunction(List *functionName, List *argTypes);
extern void DefineOperator(List *names, List *parameters);
extern void RemoveFunction(List *functionName, List *argTypes);
extern void DefineOperator(List *names, List *parameters);
-extern void RemoveOperator(List *operatorName,
- TypeName *typeName1, TypeName *typeName2);
+extern void RemoveOperator(RemoveOperStmt *stmt);
extern void DefineAggregate(List *names, List *parameters);
extern void RemoveAggregate(List *aggName, TypeName *aggType);
extern void DefineType(List *names, List *parameters);
extern void DefineAggregate(List *names, List *parameters);
extern void RemoveAggregate(List *aggName, TypeName *aggType);
extern void DefineType(List *names, List *parameters);
-extern void RemoveType(List *names);
+extern void RemoveType(List *names, DropBehavior behavior);
extern void DefineDomain(CreateDomainStmt *stmt);
extern void DefineDomain(CreateDomainStmt *stmt);
-extern void RemoveDomain(List *names, int behavior);
+extern void RemoveDomain(List *names, DropBehavior behavior);
/* support routines in commands/define.c */
/* support routines in commands/define.c */
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: tablecmds.h,v 1.4 2002/04/30 01:24:52 tgl Exp $
+ * $Id: tablecmds.h,v 1.5 2002/07/01 15:27:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
Node *flagValue, const char *flagType);
extern void AlterTableDropColumn(Oid myrelid, bool inh,
Node *flagValue, const char *flagType);
extern void AlterTableDropColumn(Oid myrelid, bool inh,
- const char *colName, int behavior);
+ const char *colName,
+ DropBehavior behavior);
extern void AlterTableAddConstraint(Oid myrelid, bool inh,
List *newConstraints);
extern void AlterTableDropConstraint(Oid myrelid, bool inh,
extern void AlterTableAddConstraint(Oid myrelid, bool inh,
List *newConstraints);
extern void AlterTableDropConstraint(Oid myrelid, bool inh,
- const char *constrName, int behavior);
+ const char *constrName,
+ DropBehavior behavior);
extern void AlterTableCreateToastTable(Oid relOid, bool silent);
extern void AlterTableCreateToastTable(Oid relOid, bool silent);
extern Oid DefineRelation(CreateStmt *stmt, char relkind);
extern Oid DefineRelation(CreateStmt *stmt, char relkind);
-extern void RemoveRelation(const RangeVar *relation);
+extern void RemoveRelation(const RangeVar *relation, DropBehavior behavior);
extern void TruncateRelation(const RangeVar *relation);
extern void TruncateRelation(const RangeVar *relation);
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: view.h,v 1.15 2002/06/20 20:29:49 momjian Exp $
+ * $Id: view.h,v 1.16 2002/07/01 15:27:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
#include "nodes/parsenodes.h"
extern void DefineView(const RangeVar *view, Query *view_parse);
#include "nodes/parsenodes.h"
extern void DefineView(const RangeVar *view, Query *view_parse);
-extern void RemoveView(const RangeVar *view);
+extern void RemoveView(const RangeVar *view, DropBehavior behavior);
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.182 2002/06/20 20:29:51 momjian Exp $
+ * $Id: parsenodes.h,v 1.183 2002/07/01 15:27:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
List *schemaElts; /* schema components (list of parsenodes) */
} CreateSchemaStmt;
List *schemaElts; /* schema components (list of parsenodes) */
} CreateSchemaStmt;
+typedef enum DropBehavior
+{
+ DROP_RESTRICT, /* drop fails if any dependent objects */
+ DROP_CASCADE /* remove dependent objects too */
+} DropBehavior;
+
/* ----------------------
* Alter Table
*
/* ----------------------
* Alter Table
*
char *name; /* column or constraint name to act on, or
* new owner */
Node *def; /* definition of new column or constraint */
char *name; /* column or constraint name to act on, or
* new owner */
Node *def; /* definition of new column or constraint */
- int behavior; /* CASCADE or RESTRICT drop behavior */
+ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
} AlterTableStmt;
/* ----------------------
} AlterTableStmt;
/* ----------------------
{
NodeTag type;
char *plname; /* PL name */
{
NodeTag type;
char *plname; /* PL name */
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} DropPLangStmt;
/* ----------------------
} DropPLangStmt;
/* ----------------------
{
NodeTag type;
List *objects; /* list of sublists of names (as Values) */
{
NodeTag type;
List *objects; /* list of sublists of names (as Values) */
- int removeType;
- int behavior; /* CASCADE or RESTRICT drop behavior */
+ int removeType; /* see #defines above */
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} DropStmt;
/* ----------------------
} DropStmt;
/* ----------------------
NodeTag type;
RangeVar *relation; /* owning relation */
char *property; /* name of rule, trigger, etc */
NodeTag type;
RangeVar *relation; /* owning relation */
char *property; /* name of rule, trigger, etc */
+ int removeType; /* see #defines above */
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} DropPropertyStmt;
/* ----------------------
} DropPropertyStmt;
/* ----------------------
NodeTag type;
List *aggname; /* aggregate to drop */
TypeName *aggtype; /* TypeName for input datatype, or NULL */
NodeTag type;
List *aggname; /* aggregate to drop */
TypeName *aggtype; /* TypeName for input datatype, or NULL */
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} RemoveAggrStmt;
/* ----------------------
} RemoveAggrStmt;
/* ----------------------
NodeTag type;
List *funcname; /* function to drop */
List *args; /* types of the arguments */
NodeTag type;
List *funcname; /* function to drop */
List *args; /* types of the arguments */
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} RemoveFuncStmt;
/* ----------------------
} RemoveFuncStmt;
/* ----------------------
NodeTag type;
List *opname; /* operator to drop */
List *args; /* types of the arguments */
NodeTag type;
List *opname; /* operator to drop */
List *args; /* types of the arguments */
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} RemoveOperStmt;
/* ----------------------
} RemoveOperStmt;
/* ----------------------