gram.c

来自「PostgreSQL7.4.6 for Linux」· C语言 代码 · 共 1,575 行 · 第 1/5 页

C
1,575
字号
#define STRICT_P 514#define SUBSTRING 515#define SYSID 516#define TABLE 517#define TEMP 518#define TEMPLATE 519#define TEMPORARY 520#define THEN 521#define TIME 522#define TIMESTAMP 523#define TO 524#define TOAST 525#define TRAILING 526#define TRANSACTION 527#define TREAT 528#define TRIGGER 529#define TRIM 530#define TRUE_P 531#define TRUNCATE 532#define TRUSTED 533#define TYPE_P 534#define UNENCRYPTED 535#define UNION 536#define UNIQUE 537#define UNKNOWN 538#define UNLISTEN 539#define UNTIL 540#define UPDATE 541#define USAGE 542#define USER 543#define USING 544#define VACUUM 545#define VALID 546#define VALIDATOR 547#define VALUES 548#define VARCHAR 549#define VARYING 550#define VERBOSE 551#define VERSION 552#define VIEW 553#define VOLATILE 554#define WHEN 555#define WHERE 556#define WITH 557#define WITHOUT 558#define WORK 559#define WRITE 560#define YEAR_P 561#define ZONE 562#define UNIONJOIN 563#define IDENT 564#define FCONST 565#define SCONST 566#define BCONST 567#define XCONST 568#define Op 569#define ICONST 570#define PARAM 571#define POSTFIXOP 572#define UMINUS 573#define TYPECAST 574/* Copy the first part of user declarations.  */#line 1 "gram.y"/*#define YYDEBUG 1*//*------------------------------------------------------------------------- * * gram.y *	  POSTGRES SQL YACC rules/actions * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION *	  $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.436.2.1 2003/11/24 16:54:15 tgl Exp $ * * HISTORY *	  AUTHOR			DATE			MAJOR EVENT *	  Andrew Yu			Sept, 1994		POSTQUEL to SQL conversion *	  Andrew Yu			Oct, 1994		lispy code conversion * * NOTES *	  CAPITALS are used to represent terminal symbols. *	  non-capitals are used to represent non-terminals. *	  SQL92-specific syntax is separated from plain SQL/Postgres syntax *	  to help isolate the non-extensible portions of the parser. * *	  In general, nothing in this file should initiate database accesses *	  nor depend on changeable state (such as SET variables).  If you do *	  database accesses, your code will fail when we have aborted the *	  current transaction and are just parsing commands to find the next *	  ROLLBACK or COMMIT.  If you make use of SET variables, then you *	  will do the wrong thing in multi-query strings like this: *			SET SQL_inheritance TO off; SELECT * FROM foo; *	  because the entire string is parsed by gram.y before the SET gets *	  executed.  Anything that depends on the database or changeable state *	  should be handled inside parse_analyze() so that it happens at the *	  right time not the wrong time.  The handling of SQL_inheritance is *	  a good example. * * WARNINGS *	  If you use a list, make sure the datum is a node so that the printing *	  routines work. * *	  Sometimes we assign constants to makeStrings. Make sure we don't free *	  those. * *------------------------------------------------------------------------- */#include "postgres.h"#include <ctype.h>#include <limits.h>#include "access/htup.h"#include "catalog/index.h"#include "catalog/namespace.h"#include "catalog/pg_type.h"#include "nodes/makefuncs.h"#include "nodes/params.h"#include "nodes/parsenodes.h"#include "parser/gramparse.h"#include "storage/lmgr.h"#include "utils/numeric.h"#include "utils/datetime.h"#include "utils/date.h"extern List *parsetree;			/* final parse result is delivered here */static bool QueryIsRule = FALSE;/* * If you need access to certain yacc-generated variables and find that * they're static by default, uncomment the next line.  (this is not a * problem, yet.) *//*#define __YYSCLASS*/static Node *makeTypeCast(Node *arg, TypeName *typename);static Node *makeStringConst(char *str, TypeName *typename);static Node *makeIntConst(int val);static Node *makeFloatConst(char *str);static Node *makeAConst(Value *v);static Node *makeRowExpr(List *opr, List *largs, List *rargs);static Node *makeDistinctExpr(List *largs, List *rargs);static Node *makeRowNullTest(NullTestType test, List *args);static DefElem *makeDefElem(char *name, Node *arg);static A_Const *makeBoolConst(bool state);static FuncCall *makeOverlaps(List *largs, List *rargs);static SelectStmt *findLeftmostSelect(SelectStmt *node);static void insertSelectOptions(SelectStmt *stmt,								List *sortClause, List *forUpdate,								Node *limitOffset, Node *limitCount);static Node *makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg);static Node *doNegate(Node *n);static void doNegateFloat(Value *v);/* Enabling traces.  */#ifndef YYDEBUG# define YYDEBUG 0#endif/* Enabling verbose error messages.  */#ifdef YYERROR_VERBOSE# undef YYERROR_VERBOSE# define YYERROR_VERBOSE 1#else# define YYERROR_VERBOSE 0#endif#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)#line 101 "gram.y"typedef union YYSTYPE {	int					ival;	char				chr;	char				*str;	const char			*keyword;	bool				boolean;	JoinType			jtype;	DropBehavior		dbehavior;	OnCommitAction		oncommit;	List				*list;	FastList			fastlist;	Node				*node;	Value				*value;	ColumnRef			*columnref;	ObjectType			objtype;	TypeName			*typnam;	DefElem				*defelt;	SortBy				*sortby;	JoinExpr			*jexpr;	IndexElem			*ielem;	Alias				*alias;	RangeVar			*range;	A_Indices			*aind;	ResTarget			*target;	PrivTarget			*privtarget;	InsertStmt			*istmt;	VariableSetStmt		*vsetstmt;} YYSTYPE;/* Line 191 of yacc.c.  */#line 842 "y.tab.c"# define yystype YYSTYPE /* obsolescent; will be withdrawn */# define YYSTYPE_IS_DECLARED 1# define YYSTYPE_IS_TRIVIAL 1#endif/* Copy the second part of user declarations.  *//* Line 214 of yacc.c.  */#line 854 "y.tab.c"#if ! defined (yyoverflow) || YYERROR_VERBOSE/* The parser invokes alloca or malloc; define the necessary symbols.  */# if YYSTACK_USE_ALLOCA#  define YYSTACK_ALLOC alloca# else#  ifndef YYSTACK_USE_ALLOCA#   if defined (alloca) || defined (_ALLOCA_H)#    define YYSTACK_ALLOC alloca#   else#    ifdef __GNUC__#     define YYSTACK_ALLOC __builtin_alloca#    endif#   endif#  endif# endif# ifdef YYSTACK_ALLOC   /* Pacify GCC's `empty if-body' warning. */#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)# else#  if defined (__STDC__) || defined (__cplusplus)#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */#   define YYSIZE_T size_t#  endif#  define YYSTACK_ALLOC malloc#  define YYSTACK_FREE free# endif#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */#if (! defined (yyoverflow) \     && (! defined (__cplusplus) \	 || (YYSTYPE_IS_TRIVIAL)))/* A type that is properly aligned for any stack member.  */union yyalloc{  short yyss;  YYSTYPE yyvs;  };/* The size of the maximum gap between one aligned stack and the next.  */# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)/* The size of an array large to enough to hold all stacks, each with   N elements.  */# define YYSTACK_BYTES(N) \     ((N) * (sizeof (short) + sizeof (YYSTYPE))				\      + YYSTACK_GAP_MAXIMUM)/* Copy COUNT objects from FROM to TO.  The source and destination do   not overlap.  */# ifndef YYCOPY#  if 1 < __GNUC__#   define YYCOPY(To, From, Count) \      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))#  else#   define YYCOPY(To, From, Count)		\      do					\	{					\	  register YYSIZE_T yyi;		\	  for (yyi = 0; yyi < (Count); yyi++)	\	    (To)[yyi] = (From)[yyi];		\	}					\      while (0)#  endif# endif/* Relocate STACK from its old location to the new one.  The   local variables YYSIZE and YYSTACKSIZE give the old and new number of   elements in the stack, and YYPTR gives the new location of the   stack.  Advance YYPTR to a properly aligned location for the next   stack.  */# define YYSTACK_RELOCATE(Stack)					\    do									\      {									\	YYSIZE_T yynewbytes;						\	YYCOPY (&yyptr->Stack, Stack, yysize);				\	Stack = &yyptr->Stack;						\	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \	yyptr += yynewbytes / sizeof (*yyptr);				\      }									\    while (0)#endif#if defined (__STDC__) || defined (__cplusplus)   typedef signed char yysigned_char;

⌨️ 快捷键说明

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