📄 gram.c
字号:
/*#define YYDEBUG 1*//*------------------------------------------------------------------------- * * gram.y * POSTGRES SQL YACC rules/actions * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $Header: /usr/local/cvsroot/pgsql/src/backend/parser/gram.y,v 2.88.2.2 1999/09/14 06:07:35 thomas 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. * * if you use list, make sure the datum is a node so that the printing * routines work * * WARNING * sometimes we assign constants to makeStrings. Make sure we don't free * those. * *------------------------------------------------------------------------- */#include <string.h>#include <ctype.h>#include "postgres.h"#include "access/htup.h"#include "nodes/parsenodes.h"#include "nodes/print.h"#include "parser/gramparse.h"#include "parser/parse_type.h"#include "utils/acl.h"#include "utils/palloc.h"#include "catalog/catname.h"#include "utils/elog.h"#include "access/xact.h"#include "storage/lmgr.h"#include "utils/numeric.h"#include "parser/analyze.h"#include "catalog/pg_type.h"#ifdef MULTIBYTE#include "mb/pg_wchar.h"#endifstatic char saved_relname[NAMEDATALEN]; /* need this for complex attributes */static bool QueryIsRule = FALSE;static List *saved_In_Expr = NIL;static Oid *param_type_info;static int pfunc_num_args;extern List *parsetree;/* * 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 char *xlateSqlFunc(char *);static char *xlateSqlType(char *);static Node *makeA_Expr(int oper, char *opname, Node *lexpr, Node *rexpr);static Node *makeRowExpr(char *opr, List *largs, List *rargs);static void mapTargetColumns(List *source, List *target);static List *makeConstantList( A_Const *node);static char *FlattenStringList(List *list);static char *fmtId(char *rawid);static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr);static void param_type_init(Oid *typev, int nargs);static Node *doNegate(Node *n);Oid param_type(int t); /* used in parse_expr.c *//* old versions of flex define this as a macro */#if defined(yywrap)#undef yywrap#endif /* yywrap */#line 94 "gram.y"typedef union{ double dval; int ival; char chr; char *str; bool boolean; bool* pboolean; /* for pg_shadow privileges */ List *list; Node *node; Value *value; Attr *attr; TypeName *typnam; DefElem *defelt; ParamString *param; SortGroupBy *sortgroupby; JoinExpr *joinexpr; IndexElem *ielem; RangeVar *range; RelExpr *relexp; A_Indices *aind; ResTarget *target; ParamNo *paramno; VersionStmt *vstmt; DefineStmt *dstmt; RuleStmt *rstmt; InsertStmt *astmt;} YYSTYPE;#include <stdio.h>#ifndef __cplusplus#ifndef __STDC__#define const#endif#endif#define YYFINAL 1776#define YYFLAG -32768#define YYNTBASE 251#define YYTRANSLATE(x) ((unsigned)(x) <= 486 ? yytranslate[x] : 528)static const short yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 238, 2, 2, 249, 250, 236, 234, 248, 235, 244, 237, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 241, 242, 232, 231, 233, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 245, 2, 246, 239, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 240, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 243, 247};#if YYDEBUG != 0static const short yyprhs[] = { 0, 0, 3, 7, 9, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 105, 114, 118, 122, 123, 125, 127, 128, 130, 132, 133, 137, 139, 143, 144, 148, 149, 154, 159, 164, 170, 174, 177, 179, 181, 183, 185, 187, 189, 192, 196, 201, 204, 208, 213, 219, 223, 228, 232, 239, 245, 248, 251, 259, 261, 263, 265, 267, 269, 271, 272, 275, 276, 280, 281, 290, 292, 295, 297, 299, 300, 302, 304, 308, 310, 311, 313, 315, 319, 323, 325, 326, 329, 331, 334, 335, 339, 341, 346, 349, 352, 355, 357, 360, 366, 370, 372, 374, 377, 381, 385, 389, 393, 397, 401, 405, 409, 413, 416, 419, 422, 426, 433, 437, 441, 446, 450, 453, 456, 458, 460, 465, 467, 472, 474, 476, 480, 482, 487, 492, 498, 509, 513, 515, 517, 519, 521, 524, 528, 532, 536, 540, 544, 548, 552, 556, 560, 563, 566, 569, 573, 580, 584, 588, 593, 597, 601, 606, 610, 614, 617, 620, 623, 626, 630, 633, 638, 642, 646, 651, 656, 662, 669, 675, 682, 686, 688, 690, 693, 696, 697, 700, 702, 703, 707, 711, 714, 716, 719, 722, 727, 728, 736, 740, 741, 745, 747, 749, 754, 757, 758, 761, 763, 766, 769, 772, 775, 777, 779, 781, 784, 786, 789, 799, 801, 802, 807, 822, 824, 826, 828, 832, 838, 840, 842, 844, 848, 850, 851, 853, 855, 857, 861, 862, 864, 866, 868, 870, 876, 880, 883, 885, 887, 889, 891, 893, 895, 897, 899, 903, 905, 909, 913, 915, 919, 921, 923, 925, 927, 930, 934, 938, 943, 948, 950, 952, 954, 956, 957, 959, 962, 964, 966, 968, 969, 972, 975, 976, 984, 987, 989, 991, 993, 997, 999, 1001, 1003, 1005, 1007, 1009, 1012, 1014, 1018, 1019, 1026, 1038, 1040, 1041, 1044, 1045, 1047, 1049, 1053, 1055, 1062, 1066, 1069, 1072, 1073, 1075, 1078, 1079, 1084, 1096, 1099, 1100, 1104, 1107, 1109, 1113, 1116, 1118, 1119, 1123, 1125, 1127, 1129, 1131, 1136, 1138, 1140, 1145, 1152, 1154, 1156, 1158, 1160, 1162, 1164, 1166, 1168, 1170, 1172, 1174, 1178, 1182, 1186, 1196, 1198, 1199, 1201, 1202, 1203, 1217, 1219, 1221, 1223, 1227, 1231, 1233, 1235, 1238, 1242, 1245, 1247, 1249, 1251, 1253, 1257, 1259, 1261, 1263, 1265, 1267, 1269, 1270, 1273, 1276, 1279, 1282, 1285, 1288, 1291, 1294, 1297, 1299, 1301, 1302, 1308, 1311, 1318, 1322, 1326, 1327, 1331, 1332, 1334, 1336, 1337, 1339, 1341, 1342, 1346, 1351, 1355, 1361, 1363, 1364, 1366, 1367, 1371, 1372, 1374, 1378, 1382, 1384, 1386, 1388, 1390, 1392, 1394, 1399, 1404, 1407, 1409, 1417, 1422, 1426, 1427, 1431, 1433, 1436, 1441, 1446, 1450, 1451, 1455, 1458, 1461, 1463, 1465, 1467, 1474, 1481, 1483, 1485, 1487, 1490, 1491, 1496, 1500, 1502,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -