⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gram.y

📁 关系型数据库 Postgresql 6.5.2
💻 Y
📖 第 1 页 / 共 5 页
字号:
					$$->defname = "default";					$$->arg = (Node *)$3;				}		;def_arg:  ColId							{  $$ = (Node *)makeString($1); }		| all_Op						{  $$ = (Node *)makeString($1); }		| NumericOnly					{  $$ = (Node *)$1; }		| Sconst						{  $$ = (Node *)makeString($1); }		| SETOF ColId				{					TypeName *n = makeNode(TypeName);					n->name = $2;					n->setof = TRUE;					n->arrayBounds = NULL;					n->typmod = -1;					$$ = (Node *)n;				}		;/***************************************************************************** * *		QUERY: *				destroy <relname1> [, <relname2> .. <relnameN> ] * *****************************************************************************/DestroyStmt:  DROP TABLE relation_name_list				{					DestroyStmt *n = makeNode(DestroyStmt);					n->relNames = $3;					n->sequence = FALSE;					$$ = (Node *)n;				}		| DROP SEQUENCE relation_name_list				{					DestroyStmt *n = makeNode(DestroyStmt);					n->relNames = $3;					n->sequence = TRUE;					$$ = (Node *)n;				}		;/***************************************************************************** * *		QUERY: *			fetch/move [forward | backward] [ # | all ] [ in <portalname> ] *			fetch [ forward | backward | absolute | relative ] *			      [ # | all | next | prior ] [ [ in | from ] <portalname> ] * *****************************************************************************/FetchStmt:	FETCH opt_direction fetch_how_many opt_portal_name				{					FetchStmt *n = makeNode(FetchStmt);					if ($2 == RELATIVE)					{						if ($3 == 0)							elog(ERROR,"FETCH/RELATIVE at current position is not supported");						$2 = FORWARD;					}					if ($3 < 0)					{						$3 = -$3;						$2 = (($2 == FORWARD)? BACKWARD: FORWARD);					}					n->direction = $2;					n->howMany = $3;					n->portalname = $4;					n->ismove = false;					$$ = (Node *)n;				}		|	MOVE opt_direction fetch_how_many opt_portal_name				{					FetchStmt *n = makeNode(FetchStmt);					if ($3 < 0)					{						$3 = -$3;						$2 = (($2 == FORWARD)? BACKWARD: FORWARD);					}					n->direction = $2;					n->howMany = $3;					n->portalname = $4;					n->ismove = TRUE;					$$ = (Node *)n;				}		;opt_direction:	FORWARD					{ $$ = FORWARD; }		| BACKWARD						{ $$ = BACKWARD; }		| RELATIVE						{ $$ = RELATIVE; }		| ABSOLUTE			{				elog(NOTICE,"FETCH/ABSOLUTE not supported, using RELATIVE");				$$ = RELATIVE;			}		| /*EMPTY*/						{ $$ = FORWARD; /* default */ }		;fetch_how_many:  Iconst					{ $$ = $1; }		| '-' Iconst					{ $$ = - $2; }		| ALL							{ $$ = 0; /* 0 means fetch all tuples*/ }		| NEXT							{ $$ = 1; }		| PRIOR							{ $$ = -1; }		| /*EMPTY*/						{ $$ = 1; /*default*/ }		;opt_portal_name:  IN name				{ $$ = $2; }		| FROM name						{ $$ = $2; }		| /*EMPTY*/						{ $$ = NULL; }		;/***************************************************************************** * *		QUERY: *				GRANT [privileges] ON [relation_name_list] TO [GROUP] grantee * *****************************************************************************/GrantStmt:  GRANT privileges ON relation_name_list TO grantee opt_with_grant				{					$$ = (Node*)makeAclStmt($2,$4,$6,'+');				}		;privileges:  ALL PRIVILEGES				{				 $$ = aclmakepriv("rwaR",0);				}		| ALL				{				 $$ = aclmakepriv("rwaR",0);				}		| operation_commalist				{				 $$ = $1;				}		;operation_commalist:  operation				{						$$ = aclmakepriv("",$1);				}		| operation_commalist ',' operation				{						$$ = aclmakepriv($1,$3);				}		;operation:  SELECT				{						$$ = ACL_MODE_RD_CHR;				}		| INSERT				{						$$ = ACL_MODE_AP_CHR;				}		| UPDATE				{						$$ = ACL_MODE_WR_CHR;				}		| DELETE				{						$$ = ACL_MODE_WR_CHR;				}		| RULE				{						$$ = ACL_MODE_RU_CHR;				}		;grantee:  PUBLIC				{						$$ = aclmakeuser("A","");				}		| GROUP ColId				{						$$ = aclmakeuser("G",$2);				}		| ColId				{						$$ = aclmakeuser("U",$1);				}		;opt_with_grant:  WITH GRANT OPTION				{					yyerror("WITH GRANT OPTION is not supported.  Only relation owners can set privileges");				 }		| /*EMPTY*/		;/***************************************************************************** * *		QUERY: *				REVOKE [privileges] ON [relation_name] FROM [user] * *****************************************************************************/RevokeStmt:  REVOKE privileges ON relation_name_list FROM grantee				{					$$ = (Node*)makeAclStmt($2,$4,$6,'-');				}		;/***************************************************************************** * *		QUERY: *				create index <indexname> on <relname> *				  using <access> "(" (<col> with <op>)+ ")" [with *				  <target_list>] * *	[where <qual>] is not supported anymore *****************************************************************************/IndexStmt:	CREATE index_opt_unique INDEX index_name ON relation_name			access_method_clause '(' index_params ')' opt_with				{					/* should check that access_method is valid,					   etc ... but doesn't */					IndexStmt *n = makeNode(IndexStmt);					n->unique = $2;					n->idxname = $4;					n->relname = $6;					n->accessMethod = $7;					n->indexParams = $9;					n->withClause = $11;					n->whereClause = NULL;					$$ = (Node *)n;				}		;index_opt_unique:  UNIQUE						{ $$ = TRUE; }		| /*EMPTY*/								{ $$ = FALSE; }		;access_method_clause:  USING access_method		{ $$ = $2; }		| /*EMPTY*/								{ $$ = "btree"; }		;index_params:  index_list						{ $$ = $1; }		| func_index							{ $$ = lcons($1,NIL); }		;index_list:  index_list ',' index_elem			{ $$ = lappend($1, $3); }		| index_elem							{ $$ = lcons($1, NIL); }		;func_index:  func_name '(' name_list ')' opt_type opt_class				{					$$ = makeNode(IndexElem);					$$->name = $1;					$$->args = $3;					$$->class = $6;					$$->typename = $5;				}		  ;index_elem:  attr_name opt_type opt_class				{					$$ = makeNode(IndexElem);					$$->name = $1;					$$->args = NIL;					$$->class = $3;					$$->typename = $2;				}		;opt_type:  ':' Typename							{ $$ = $2; }		| FOR Typename							{ $$ = $2; }		| /*EMPTY*/								{ $$ = NULL; }		;/* opt_class "WITH class" conflicts with preceeding opt_type *  for Typename of "TIMESTAMP WITH TIME ZONE" * So, remove "WITH class" from the syntax. OK?? * - thomas 1997-10-12 *		| WITH class							{ $$ = $2; } */opt_class:  class								{ $$ = $1; }		| USING class							{ $$ = $2; }		| /*EMPTY*/								{ $$ = NULL; }		;/***************************************************************************** * *		QUERY: *				extend index <indexname> [where <qual>] * *****************************************************************************/ExtendStmt:  EXTEND INDEX index_name where_clause				{					ExtendStmt *n = makeNode(ExtendStmt);					n->idxname = $3;					n->whereClause = $4;					$$ = (Node *)n;				}		;/***************************************************************************** * *		QUERY: *				execute recipe <recipeName> * *****************************************************************************//* NOT USEDRecipeStmt:  EXECUTE RECIPE recipe_name				{					RecipeStmt *n;					if (!IsTransactionBlock())						elog(ERROR,"EXECUTE RECIPE may only be used in begin/end transaction blocks");					n = makeNode(RecipeStmt);					n->recipeName = $3;					$$ = (Node *)n;				}		;*//***************************************************************************** * *		QUERY: *				define function <fname> *					   (language = <lang>, returntype = <typename> *						[, arch_pct = <percentage | pre-defined>] *						[, disk_pct = <percentage | pre-defined>] *						[, byte_pct = <percentage | pre-defined>] *						[, perbyte_cpu = <int | pre-defined>] *						[, percall_cpu = <int | pre-defined>] *						[, iscachable]) *						[arg is (<type-1> { , <type-n>})] *						as <filename or code in language as appropriate> * *****************************************************************************/ProcedureStmt:	CREATE FUNCTION func_name func_args			 RETURNS func_return opt_with AS Sconst LANGUAGE Sconst				{					ProcedureStmt *n = makeNode(ProcedureStmt);					n->funcname = $3;					n->defArgs = $4;					n->returnType = $6;					n->withClause = $7;					n->as = $9;					n->language = $11;					$$ = (Node *)n;				};opt_with:  WITH definition						{ $$ = $2; }		| /*EMPTY*/								{ $$ = NIL; }		;func_args:  '(' func_args_list ')'				{ $$ = $2; }		| '(' ')'								{ $$ = NIL; }		;func_args_list:  TypeId				{	$$ = lcons(makeString($1),NIL); }		| func_args_list ',' TypeId				{	$$ = lappend($1,makeString($3)); }		;func_return:  set_opt TypeId				{					TypeName *n = makeNode(TypeName);					n->name = $2;					n->setof = $1;					n->arrayBounds = NULL;					$$ = (Node *)n;				}		;set_opt:  SETOF									{ $$ = TRUE; }		| /*EMPTY*/								{ $$ = FALSE; }		;/***************************************************************************** * *		QUERY: * *		remove function <funcname> *				(REMOVE FUNCTION "funcname" (arg1, arg2, ...)) *		remove aggregate <aggname> *				(REMOVE AGGREGATE "aggname" "aggtype") *		remove operator <opname> *				(REMOVE OPERATOR "opname" (leftoperand_typ rightoperand_typ)) *		remove type <typename> *				(REMOVE TYPE "typename") *		remove rule <rulename> *				(REMOVE RULE "rulename") * *****************************************************************************/RemoveStmt:  DROP remove_type name				{					RemoveStmt *n = makeNode(RemoveStmt);					n->removeType = $2;					n->name = $3;					$$ = (Node *)n;				}		;remove_type:  TYPE_P							{  $$ = TYPE_P; }		| INDEX									{  $$ = INDEX; }		| RULE									{  $$ = RULE; }		| VIEW									{  $$ = VIEW; }		;RemoveAggrStmt:  DROP AGGREGATE name aggr_argtype				{						RemoveAggrStmt *n = makeNode(RemoveAggrStmt);						n->aggname = $3;						n->aggtype = $4;						$$ = (Node *)n;				}		;aggr_argtype:  name								{ $$ = $1; }		| '*'									{ $$ = NULL; }		;RemoveFuncStmt:  DROP FUNCTION func_name func_args				{					RemoveFuncStmt *n = makeNode(RemoveFuncStmt);					n->funcname = $3;					n->args = $4;					$$ = (Node *)n;				}		;RemoveOperStmt:  DROP OPERATOR all_Op '(' oper_argtypes ')'				{					RemoveOperStmt *n = makeNode(RemoveOperStmt);					n->opname = $3;					n->args = $5;					$$ = (Node *)n;				}		;all_Op:  Op | MathOp;MathOp:	'+'				{ $$ = "+"; }		| '-'			{ $$ = "-"; }		| '*'			{ $$ = "*"; }		| '/'			{ $$ = "/"; }		| '%'			{ $$ = "%"; }		| '<'			{ $$ = "<"; }		| '>'			{ $$ = ">"; }		| '='			{ $$ = "="; }		;oper_argtypes:	name				{				   elog(ERROR,"parser: argument type missing (use NONE for unary operators)");				}		| name ',' name				{ $$ = makeList(makeString($1), makeString($3), -1); }		| NONE ',' name			/* left unary */				{ $$ = makeList(NULL, makeString($3), -1); }		| name ',' NONE			/* right unary */				{ $$ = makeList(makeString($1), NULL, -1); }		;/***************************************************************************** * *		QUERY: *				rename <attrname1> in <relname> [*] to <attrname2> *				rename <relname1> to <relname2> * *****************************************************************************/RenameStmt:  ALTER TABLE relation_name opt_inh_star				  RENAME opt_column opt_name TO name				{					RenameStmt *n = makeNode(RenameStmt);					n->relname = $3;					n->inh = $4;					n->column = $7;					n->newname = $9;					$$ = (Node *)n;				}		;opt_name:  name							{ $$ = $1; }		| /*EMPTY*/						{ $$ = NULL; }		;opt_column:  COLUMN						{ $$ = COLUMN; }		| /*EMPTY*/						{ $$ = 0; }		;/***************************************************************************** * *		QUERY:	Define Rewrite Rule , Define Tuple Rule *				Define Rule <old rules > * *		only rewrite rule is supported -- ay 9/94 * *****************************************************************************/RuleStmt:  CREATE RULE name AS		   { QueryIsRule=TRUE; }		   ON event TO event_object where_clause		   DO opt_instead RuleActionList				{					RuleStmt *n = makeNode(RuleStmt);					n->rulename = $3;					n->event = $7;					n->object = $9;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -