/*****************************************************************************
 *
 *		QUERY:
 *				DELETE STATEMENTS
 *
 *****************************************************************************/
DeleteStmt: opt_with_clause DELETE_P FROM relation_expr_opt_alias
			using_clause where_or_current_clause returning_clause
				{
					PGDeleteStmt *n = makeNode(PGDeleteStmt);
					n->relation = $4;
					n->usingClause = $5;
					n->whereClause = $6;
					n->returningList = $7;
					n->withClause = $1;
					$$ = (PGNode *)n;
				}
			| TRUNCATE opt_table relation_expr_opt_alias
			    {
					PGDeleteStmt *n = makeNode(PGDeleteStmt);
					n->relation = $3;
					n->usingClause = NULL;
					n->whereClause = NULL;
					n->returningList = NULL;
					n->withClause = NULL;
					$$ = (PGNode *)n;
			    }
		;


relation_expr_opt_alias: relation_expr					%prec UMINUS
				{
					$$ = $1;
				}
			| relation_expr ColId
				{
					PGAlias *alias = makeNode(PGAlias);
					alias->aliasname = $2;
					$1->alias = alias;
					$$ = $1;
				}
			| relation_expr AS ColId
				{
					PGAlias *alias = makeNode(PGAlias);
					alias->aliasname = $3;
					$1->alias = alias;
					$$ = $1;
				}
		;


where_or_current_clause:
			WHERE a_expr							{ $$ = $2; }
			| /*EMPTY*/								{ $$ = NULL; }
		;



using_clause:
				USING from_list_opt_comma						{ $$ = $2; }
			| /*EMPTY*/								{ $$ = NIL; }
		;
