📄 gram.c
字号:
#define REPLACE 503#define RESET 504#define RESTART 505#define RESTRICT 506#define RETURNS 507#define REVOKE 508#define RIGHT 509#define ROLE 510#define ROLLBACK 511#define ROW 512#define ROWS 513#define RULE 514#define SAVEPOINT 515#define SCHEMA 516#define SCROLL 517#define SECOND_P 518#define SECURITY 519#define SELECT 520#define SEQUENCE 521#define SERIALIZABLE 522#define SESSION 523#define SESSION_USER 524#define SET 525#define SETOF 526#define SHARE 527#define SHOW 528#define SIMILAR 529#define SIMPLE 530#define SMALLINT 531#define SOME 532#define STABLE 533#define START 534#define STATEMENT 535#define STATISTICS 536#define STDIN 537#define STDOUT 538#define STORAGE 539#define STRICT_P 540#define SUBSTRING 541#define SUPERUSER_P 542#define SYMMETRIC 543#define SYSID 544#define SYSTEM_P 545#define TABLE 546#define TABLESPACE 547#define TEMP 548#define TEMPLATE 549#define TEMPORARY 550#define THEN 551#define TIME 552#define TIMESTAMP 553#define TO 554#define TOAST 555#define TRAILING 556#define TRANSACTION 557#define TREAT 558#define TRIGGER 559#define TRIM 560#define TRUE_P 561#define TRUNCATE 562#define TRUSTED 563#define TYPE_P 564#define UNCOMMITTED 565#define UNENCRYPTED 566#define UNION 567#define UNIQUE 568#define UNKNOWN 569#define UNLISTEN 570#define UNTIL 571#define UPDATE 572#define USER 573#define USING 574#define VACUUM 575#define VALID 576#define VALIDATOR 577#define VALUES 578#define VARCHAR 579#define VARYING 580#define VERBOSE 581#define VIEW 582#define VOLATILE 583#define WHEN 584#define WHERE 585#define WITH 586#define WITHOUT 587#define WORK 588#define WRITE 589#define YEAR_P 590#define ZONE 591#define UNIONJOIN 592#define IDENT 593#define FCONST 594#define SCONST 595#define BCONST 596#define XCONST 597#define Op 598#define ICONST 599#define PARAM 600#define POSTFIXOP 601#define UMINUS 602#define TYPECAST 603/* 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-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.511.2.2 2006/01/31 22:40:12 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 "catalog/index.h"#include "catalog/namespace.h"#include "nodes/makefuncs.h"#include "parser/gramparse.h"#include "storage/lmgr.h"#include "utils/date.h"#include "utils/datetime.h"#include "utils/numeric.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 *makeColumnRef(char *relname, List *indirection);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 *makeRowNullTest(NullTestType test, RowExpr *row);static DefElem *makeDefElem(char *name, Node *arg);static A_Const *makeBoolAConst(bool state);static FuncCall *makeOverlaps(List *largs, List *rargs);static void check_qualified_name(List *names);static List *check_func_name(List *names);static List *extractArgTypes(List *parameters);static SelectStmt *findLeftmostSelect(SelectStmt *node);static void insertSelectOptions(SelectStmt *stmt, List *sortClause, Node *lockingClause, 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 100 "gram.y"typedef union YYSTYPE { int ival; char chr; char *str; const char *keyword; bool boolean; JoinType jtype; DropBehavior dbehavior; OnCommitAction oncommit; ContainsOids withoids; List *list; Node *node; Value *value; ObjectType objtype; TypeName *typnam; FunctionParameter *fun_param; FunctionParameterMode fun_param_mode; FuncWithArgs *funwithargs; 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 901 "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 913 "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)))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -