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

📄 gram.y

📁 关系型数据库 Postgresql 6.5.2
💻 Y
📖 第 1 页 / 共 5 页
字号:
user_group_clause:  IN GROUP user_group_list	{ $$ = $3; }			| /*EMPTY*/							{ $$ = NULL; }		;user_valid_clause:  VALID UNTIL SCONST			{ $$ = $3; }			| /*EMPTY*/							{ $$ = NULL; }		;/***************************************************************************** * * Set PG internal variable *	  SET name TO 'var_value' * Include SQL92 syntax (thomas 1997-10-22): *    SET TIME ZONE 'var_value' * *****************************************************************************/VariableSetStmt:  SET ColId TO var_value				{					VariableSetStmt *n = makeNode(VariableSetStmt);					n->name  = $2;					n->value = $4;					$$ = (Node *) n;				}		| SET ColId '=' var_value				{					VariableSetStmt *n = makeNode(VariableSetStmt);					n->name  = $2;					n->value = $4;					$$ = (Node *) n;				}		| SET TIME ZONE zone_value				{					VariableSetStmt *n = makeNode(VariableSetStmt);					n->name  = "timezone";					n->value = $4;					$$ = (Node *) n;				}		| SET TRANSACTION ISOLATION LEVEL opt_level				{					VariableSetStmt *n = makeNode(VariableSetStmt);					n->name  = "XactIsoLevel";					n->value = $5;					$$ = (Node *) n;				}		| SET NAMES encoding				{#ifdef MULTIBYTE					VariableSetStmt *n = makeNode(VariableSetStmt);					n->name  = "client_encoding";					n->value = $3;					$$ = (Node *) n;#else					elog(ERROR, "SET NAMES is not supported");#endif				}		;opt_level:  READ COMMITTED					{ $$ = "committed"; }		| SERIALIZABLE						{ $$ = "serializable"; }		;var_value:  Sconst			{ $$ = $1; }		| DEFAULT			{ $$ = NULL; }		;zone_value:  Sconst			{ $$ = $1; }		| DEFAULT			{ $$ = NULL; }		| LOCAL				{ $$ = NULL; }		;VariableShowStmt:  SHOW ColId				{					VariableShowStmt *n = makeNode(VariableShowStmt);					n->name  = $2;					$$ = (Node *) n;				}		| SHOW TIME ZONE				{					VariableShowStmt *n = makeNode(VariableShowStmt);					n->name  = "timezone";					$$ = (Node *) n;				}		| SHOW TRANSACTION ISOLATION LEVEL				{					VariableShowStmt *n = makeNode(VariableShowStmt);					n->name  = "XactIsoLevel";					$$ = (Node *) n;				}		;VariableResetStmt:	RESET ColId				{					VariableResetStmt *n = makeNode(VariableResetStmt);					n->name  = $2;					$$ = (Node *) n;				}		| RESET TIME ZONE				{					VariableResetStmt *n = makeNode(VariableResetStmt);					n->name  = "timezone";					$$ = (Node *) n;				}		| RESET TRANSACTION ISOLATION LEVEL				{					VariableResetStmt *n = makeNode(VariableResetStmt);					n->name  = "XactIsoLevel";					$$ = (Node *) n;				}		;/***************************************************************************** * *		QUERY : *				addattr ( attr1 = type1 .. attrn = typen ) to <relname> [*] * *****************************************************************************/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;				}		;alter_clause:  ADD opt_column columnDef				{					$$ = $3;				}			| ADD '(' OptTableElementList ')'				{					Node *lp = lfirst($3);					if (length($3) != 1)						elog(ERROR,"ALTER TABLE/ADD() allows one column only");					$$ = lp;				}			| DROP opt_column ColId				{	elog(ERROR,"ALTER TABLE/DROP COLUMN not yet implemented"); }			| ALTER opt_column ColId SET DEFAULT default_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"); }		;/***************************************************************************** * *		QUERY : *				close <optname> * *****************************************************************************/ClosePortalStmt:  CLOSE opt_id				{					ClosePortalStmt *n = makeNode(ClosePortalStmt);					n->portalname = $2;					$$ = (Node *)n;				}		;/***************************************************************************** * *		QUERY : *				COPY [BINARY] <relname> FROM/TO *				[USING DELIMITERS <delimiter>] * *****************************************************************************/CopyStmt:  COPY opt_binary relation_name opt_with_copy copy_dirn copy_file_name copy_delimiter				{					CopyStmt *n = makeNode(CopyStmt);					n->binary = $2;					n->relname = $3;					n->oids = $4;					n->direction = $5;					n->filename = $6;					n->delimiter = $7;					$$ = (Node *)n;				}		;copy_dirn:	TO				{ $$ = TO; }		| FROM				{ $$ = FROM; }		;/* * copy_file_name NULL indicates stdio is used. Whether stdin or stdout is * used depends on the direction. (It really doesn't make sense to copy from * stdout. We silently correct the "typo".		 - AY 9/94 */copy_file_name:  Sconst							{ $$ = $1; }		| STDIN									{ $$ = NULL; }		| STDOUT								{ $$ = NULL; }		;opt_binary:  BINARY								{ $$ = TRUE; }		| /*EMPTY*/								{ $$ = FALSE; }		;opt_with_copy:	WITH OIDS						{ $$ = TRUE; }		| /*EMPTY*/								{ $$ = FALSE; }		;/* * the default copy delimiter is tab but the user can configure it */copy_delimiter:  USING DELIMITERS Sconst		{ $$ = $3; }		| /*EMPTY*/								{ $$ = "\t"; }		;/***************************************************************************** * *		QUERY : *				CREATE relname * *****************************************************************************/CreateStmt:  CREATE OptTemp TABLE relation_name '(' OptTableElementList ')'				OptInherit				{					CreateStmt *n = makeNode(CreateStmt);					n->istemp = $2;					n->relname = $4;					n->tableElts = $6;					n->inhRelnames = $8;					n->constraints = NIL;					$$ = (Node *)n;				}		;OptTemp:  OptTempType						{ $$ = $1; }			| OptTempScope OptTempType		{ $$ = $2; }		;OptTempType:  TEMP							{ $$ = TRUE; }			| TEMPORARY						{ $$ = TRUE; }			| /*EMPTY*/						{ $$ = FALSE; }		;OptTempScope:  GLOBAL				{					elog(ERROR, "GLOBAL TEMPORARY TABLE is not currently supported");					$$ = TRUE;				}			| LOCAL				{					 $$ = FALSE;				}		;OptTableElementList:  OptTableElementList ',' OptTableElement				{					if ($3 != NULL)						$$ = lappend($1, $3);					else						$$ = $1;				}			| OptTableElement				{					if ($1 != NULL)						$$ = lcons($1, NIL);					else						$$ = NULL;				}			| /*EMPTY*/							{ $$ = NULL; }		;OptTableElement:  columnDef						{ $$ = $1; }			| TableConstraint					{ $$ = $1; }		;columnDef:  ColId Typename ColQualifier				{					ColumnDef *n = makeNode(ColumnDef);					n->colname = $1;					n->typename = $2;					n->defval = NULL;					n->is_not_null = FALSE;					n->constraints = $3;					$$ = (Node *)n;				}			| ColId SERIAL ColPrimaryKey				{					ColumnDef *n = makeNode(ColumnDef);					n->colname = $1;					n->typename = makeNode(TypeName);					n->typename->name = xlateSqlType("integer");					n->defval = NULL;					n->is_not_null = TRUE;					n->is_sequence = TRUE;					n->constraints = $3;					$$ = (Node *)n;				}		;ColQualifier:  ColQualList						{ $$ = $1; }			| /*EMPTY*/							{ $$ = NULL; }		;ColQualList:  ColQualList ColConstraint				{					if ($2 != NULL)						$$ = lappend($1, $2);					else						$$ = $1;				}			| ColConstraint				{					if ($1 != NULL)						$$ = lcons($1, NIL);					else						$$ = NULL;				}		;ColPrimaryKey:  PRIMARY KEY				{					Constraint *n = makeNode(Constraint);					n->contype = CONSTR_PRIMARY;					n->name = NULL;					n->def = NULL;					n->keys = NULL;					$$ = lcons((Node *)n, NIL);				}			| /*EMPTY*/							{ $$ = NULL; }		;ColConstraint:		CONSTRAINT name ColConstraintElem				{						Constraint *n = (Constraint *)$3;						if (n != NULL) n->name = fmtId($2);						$$ = $3;				}		| ColConstraintElem				{ $$ = $1; }		;/* DEFAULT NULL is already the default for Postgres. * Bue define it here and carry it forward into the system * to make it explicit. * - thomas 1998-09-13 * WITH NULL and NULL are not SQL92-standard syntax elements, * so leave them out. Use DEFAULT NULL to explicitly indicate * that a column may have that value. WITH NULL leads to * shift/reduce conflicts with WITH TIME ZONE anyway. * - thomas 1999-01-08 */ColConstraintElem:  CHECK '(' constraint_expr ')'				{					Constraint *n = makeNode(Constraint);					n->contype = CONSTR_CHECK;					n->name = NULL;					n->def = FlattenStringList($3);					n->keys = NULL;					$$ = (Node *)n;				}			| DEFAULT NULL_P				{					Constraint *n = makeNode(Constraint);					n->contype = CONSTR_DEFAULT;					n->name = NULL;					n->def = NULL;					n->keys = NULL;					$$ = (Node *)n;				}			| DEFAULT default_expr				{					Constraint *n = makeNode(Constraint);					n->contype = CONSTR_DEFAULT;					n->name = NULL;					n->def = FlattenStringList($2);					n->keys = NULL;					$$ = (Node *)n;				}			| NOT NULL_P				{					Constraint *n = makeNode(Constraint);					n->contype = CONSTR_NOTNULL;					n->name = NULL;					n->def = NULL;					n->keys = NULL;					$$ = (Node *)n;				}			| UNIQUE				{					Constraint *n = makeNode(Constraint);					n->contype = CONSTR_UNIQUE;					n->name = NULL;					n->def = NULL;					n->keys = NULL;					$$ = (Node *)n;				}			| PRIMARY KEY				{					Constraint *n = makeNode(Constraint);					n->contype = CONSTR_PRIMARY;					n->name = NULL;					n->def = NULL;					n->keys = NULL;					$$ = (Node *)n;				}			| REFERENCES ColId opt_column_list key_match key_actions				{					elog(NOTICE,"CREATE TABLE/FOREIGN KEY clause ignored; not yet implemented");					$$ = NULL;				}		;default_list:  default_list ',' default_expr				{					$$ = lappend($1,makeString(","));					$$ = nconc($$, $3);				}			| default_expr				{					$$ = $1;				}		;/* The Postgres default column value is NULL. * Rather than carrying DEFAULT NULL forward as a clause, * let's just have it be a no-op.			| NULL_P				{	$$ = lcons( makeString("NULL"), NIL); } * - thomas 1998-09-13 */default_expr:  AexprConst				{	$$ = makeConstantList((A_Const *) $1); }			| '-' default_expr %prec UMINUS				{	$$ = lcons( makeString( "-"), $2); }			| default_expr '+' default_expr				{	$$ = nconc( $1, lcons( makeString( "+"), $3)); }			| default_expr '-' default_expr				{	$$ = nconc( $1, lcons( makeString( "-"), $3)); }			| default_expr '/' default_expr				{	$$ = nconc( $1, lcons( makeString( "/"), $3)); }			| default_expr '%' default_expr				{	$$ = nconc( $1, lcons( makeString( "%"), $3)); }			| default_expr '*' default_expr				{	$$ = nconc( $1, lcons( makeString( "*"), $3)); }			| default_expr '^' default_expr				{	$$ = nconc( $1, lcons( makeString( "^"), $3)); }			| default_expr '=' default_expr				{	elog(ERROR,"boolean expressions not supported in DEFAULT"); }			| default_expr '<' default_expr				{	elog(ERROR,"boolean expressions not supported in DEFAULT"); }			| default_expr '>' default_expr				{	elog(ERROR,"boolean expressions not supported in DEFAULT"); }			| ':' default_expr				{	$$ = lcons( makeString( ":"), $2); }			| ';' default_expr				{	$$ = lcons( makeString( ";"), $2); }			| '|' default_expr				{	$$ = lcons( makeString( "|"), $2); }			| default_expr TYPECAST Typename				{					$3->name = fmtId($3->name);					$$ = nconc( lcons( makeString( "CAST"), $1), makeList( makeString("AS"), $3, -1));				}			| CAST '(' default_expr AS Typename ')'				{					$5->name = fmtId($5->name);					$$ = nconc( lcons( makeString( "CAST"), $3), makeList( makeString("AS"), $5, -1));				}			| '(' default_expr ')'				{	$$ = lappend( lcons( makeString( "("), $2), makeString( ")")); }			| func_name '(' ')'				{					$$ = makeList( makeString($1), makeString("("), -1);					$$ = lappend( $$, makeString(")"));				}			| func_name '(' default_list ')'				{					$$ = makeList( makeString($1), makeString("("), -1);					$$ = nconc( $$, $3);					$$ = lappend( $$, makeString(")"));				}			| default_expr Op default_expr				{					if (!strcmp("<=", $2) || !strcmp(">=", $2))						elog(ERROR,"boolean expressions not supported in DEFAULT");					$$ = nconc( $1, lcons( makeString( $2), $3));				}			| Op default_expr				{	$$ = lcons( makeString( $1), $2); }			| default_expr Op				{	$$ = lappend( $1, makeString( $2)); }			/* XXX - thomas 1997-10-07 v6.2 function-specific code to be changed */			| CURRENT_DATE				{	$$ = lcons( makeString( "date( 'current'::datetime + '0 sec')"), NIL); }			| CURRENT_TIME				{	$$ = lcons( makeString( "'now'::time"), NIL); }			| CURRENT_TIME '(' Iconst ')'				{					if ($3 != 0)						elog(NOTICE,"CURRENT_TIME(%d) precision not implemented; zero used instead",$3);					$$ = lcons( makeString( "'now'::time"), NIL);				}			| CURRENT_TIMESTAMP				{	$$ = lcons( makeString( "now()"), NIL); }			| CURRENT_TIMESTAMP '(' Iconst ')'				{					if ($3 != 0)						elog(NOTICE,"CURRENT_TIMESTAMP(%d) precision not implemented; zero used instead",$3);					$$ = lcons( makeString( "now()"), NIL);				}			| CURRENT_USER				{	$$ = lcons( makeString( "CURRENT_USER"), NIL); }

⌨️ 快捷键说明

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