aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
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/parser
parenta4e1304ed1700c9831fdacc908fa0461ef0f5151 (diff)
downloadpostgresql-759fba48734fdb93094ed6fe6b0d0c4d533fd0ca.tar.gz
postgresql-759fba48734fdb93094ed6fe6b0d0c4d533fd0ca.zip
Included all yacc and lex files into the distribution.
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/gram.y105
1 files changed, 71 insertions, 34 deletions
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"); }
- ;
/*****************************************************************************