head 4.16; access; symbols Version_2_1:2.31 Version_2:1.90 C_Demo_1:1.46; locks; strict; comment @ * @; 4.16 date 92.08.26.21.09.57; author mer; state Exp; branches; next 4.15; 4.15 date 92.08.25.17.49.04; author mer; state Exp; branches; next 4.14; 4.14 date 92.08.13.22.15.31; author mer; state Exp; branches; next 4.13; 4.13 date 92.08.03.18.15.19; author mer; state Exp; branches; next 4.12; 4.12 date 92.07.29.20.25.53; author mao; state Exp; branches; next 4.11; 4.11 date 92.07.29.17.53.22; author mer; state Exp; branches; next 4.10; 4.10 date 92.07.29.17.05.58; author mer; state Exp; branches; next 4.9; 4.9 date 92.07.29.04.34.00; author mer; state Exp; branches; next 4.8; 4.8 date 92.07.28.22.47.17; author sunita; state Exp; branches; next 4.7; 4.7 date 92.07.26.23.49.29; author mao; state Exp; branches; next 4.6; 4.6 date 92.07.24.22.00.26; author mao; state Exp; branches; next 4.5; 4.5 date 92.07.24.21.19.09; author mao; state Exp; branches; next 4.4; 4.4 date 92.07.17.23.28.04; author mao; state Exp; branches; next 4.3; 4.3 date 92.07.13.01.28.02; author joey; state Exp; branches; next 4.2; 4.2 date 92.07.12.16.45.44; author mao; state Exp; branches; next 4.1; 4.1 date 92.07.11.06.13.12; author mao; state Exp; branches; next 2.101; 2.101 date 92.07.10.21.25.55; author mao; state Exp; branches; next 2.100; 2.100 date 92.07.08.23.41.04; author sunita; state Exp; branches; next 2.99; 2.99 date 92.07.08.20.46.37; author joey; state Exp; branches; next 2.98; 2.98 date 92.07.08.06.31.58; author mao; state Exp; branches; next 2.97; 2.97 date 92.07.08.06.06.33; author mao; state Exp; branches; next 2.96; 2.96 date 92.07.06.22.21.04; author mao; state Exp; branches; next 2.95; 2.95 date 92.07.06.05.02.36; author mao; state Exp; branches; next 2.94; 2.94 date 92.07.04.04.03.30; author mao; state Exp; branches; next 2.93; 2.93 date 92.07.02.18.22.10; author mao; state Exp; branches; next 2.92; 2.92 date 92.07.01.16.44.19; author mao; state Exp; branches; next 2.91; 2.91 date 92.07.01.07.54.26; author mao; state Exp; branches; next 2.90; 2.90 date 92.07.01.02.35.33; author joey; state Exp; branches; next 2.89; 2.89 date 92.06.30.22.17.27; author joey; state Exp; branches; next 2.88; 2.88 date 92.06.30.06.59.33; author joey; state Exp; branches; next 2.87; 2.87 date 92.06.30.01.28.56; author joey; state Exp; branches; next 2.86; 2.86 date 92.06.29.23.40.37; author joey; state Exp; branches; next 2.85; 2.85 date 92.06.29.19.23.58; author joey; state Exp; branches; next 2.84; 2.84 date 92.06.28.18.55.21; author mao; state Exp; branches; next 2.83; 2.83 date 92.06.28.05.43.19; author mao; state Exp; branches; next 2.82; 2.82 date 92.06.27.18.48.47; author mao; state Exp; branches; next 2.81; 2.81 date 92.06.26.02.55.38; author joey; state Exp; branches; next 2.80; 2.80 date 92.06.25.22.14.57; author sunita; state Exp; branches; next 2.79; 2.79 date 92.06.25.06.26.36; author joey; state Exp; branches; next 2.78; 2.78 date 92.06.23.23.51.17; author mao; state Exp; branches; next 2.77; 2.77 date 92.06.23.21.51.03; author mao; state Exp; branches; next 2.76; 2.76 date 92.03.31.23.12.04; author mer; state Exp; branches; next 2.75; 2.75 date 92.03.06.22.18.06; author clarsen; state Exp; branches; next 2.74; 2.74 date 92.03.06.07.57.49; author mer; state Exp; branches; next 2.73; 2.73 date 92.03.05.22.52.46; author clarsen; state Exp; branches; next 2.72; 2.72 date 92.02.25.15.30.08; author clarsen; state Exp; branches; next 2.71; 2.71 date 92.02.12.13.26.15; author olson; state Exp; branches; next 2.70; 2.70 date 92.02.07.10.49.55; author hong; state Exp; branches; next 2.69; 2.69 date 92.02.05.22.18.13; author mer; state Exp; branches; next 2.68; 2.68 date 91.12.12.02.17.11; author mer; state Exp; branches; next 2.67; 2.67 date 91.12.10.17.51.30; author mer; state Exp; branches; next 2.66; 2.66 date 91.11.21.05.22.49; author mer; state Exp; branches; next 2.65; 2.65 date 91.11.20.13.11.07; author mer; state Exp; branches; next 2.64; 2.64 date 91.11.19.18.18.43; author glass; state Exp; branches; next 2.63; 2.63 date 91.11.17.21.09.05; author mer; state Exp; branches; next 2.62; 2.62 date 91.11.13.08.45.21; author clarsen; state Exp; branches; next 2.61; 2.61 date 91.11.05.07.21.04; author mer; state Exp; branches; next 2.60; 2.60 date 91.10.25.02.19.12; author joey; state Exp; branches; next 2.59; 2.59 date 91.09.29.00.21.06; author mer; state Exp; branches; next 2.58; 2.58 date 91.09.08.16.21.26; author glass; state Exp; branches; next 2.57; 2.57 date 91.08.18.01.54.06; author caetta; state Exp; branches; next 2.56; 2.56 date 91.08.15.22.27.48; author glass; state Exp; branches; next 2.55; 2.55 date 91.08.15.17.09.33; author mao; state Exp; branches; next 2.54; 2.54 date 91.08.15.17.01.50; author caetta; state Exp; branches; next 2.53; 2.53 date 91.08.14.23.03.37; author glass; state Exp; branches; next 2.52; 2.52 date 91.08.02.22.27.00; author hong; state Exp; branches; next 2.51; 2.51 date 91.07.22.22.20.29; author mao; state Exp; branches; next 2.50; 2.50 date 91.07.09.00.19.25; author mao; state Exp; branches; next 2.49; 2.49 date 91.07.03.00.42.55; author mao; state Exp; branches; next 2.48; 2.48 date 91.05.05.19.42.00; author mao; state Exp; branches; next 2.47; 2.47 date 91.05.01.13.45.46; author choi; state Exp; branches; next 2.46; 2.46 date 91.05.01.02.50.45; author cimarron; state Exp; branches; next 2.45; 2.45 date 91.04.24.20.57.46; author mao; state Exp; branches; next 2.44; 2.44 date 91.04.12.15.58.09; author choi; state Exp; branches; next 2.43; 2.43 date 91.04.11.16.01.25; author choi; state Exp; branches; next 2.42; 2.42 date 91.04.08.14.56.25; author choi; state Exp; branches; next 2.41; 2.41 date 91.03.29.05.29.31; author kemnitz; state Exp; branches; next 2.40; 2.40 date 91.03.28.22.48.36; author kemnitz; state Exp; branches; next 2.39; 2.39 date 91.03.28.22.23.43; author kemnitz; state Exp; branches; next 2.38; 2.38 date 91.03.28.13.31.27; author choi; state Exp; branches; next 2.37; 2.37 date 91.03.27.23.03.29; author choi; state Exp; branches; next 2.36; 2.36 date 91.03.27.19.12.32; author choi; state Exp; branches; next 2.35; 2.35 date 91.03.27.16.57.38; author choi; state Exp; branches; next 2.34; 2.34 date 91.03.19.19.03.47; author sp; state Exp; branches; next 2.33; 2.33 date 91.03.19.13.49.27; author sp; state Exp; branches; next 2.32; 2.32 date 91.03.16.17.27.31; author sp; state Exp; branches; next 2.31; 2.31 date 91.03.09.13.53.05; author kemnitz; state Exp; branches; next 2.30; 2.30 date 91.03.07.16.34.04; author choi; state Exp; branches; next 2.29; 2.29 date 91.03.04.13.41.53; author mao; state Exp; branches; next 2.28; 2.28 date 91.03.03.19.23.36; author mao; state Exp; branches; next 2.27; 2.27 date 91.02.28.20.54.19; author mao; state Exp; branches; next 2.26; 2.26 date 91.02.25.22.08.40; author mao; state Exp; branches; next 2.25; 2.25 date 91.02.25.16.52.37; author sp; state Exp; branches; next 2.24; 2.24 date 91.02.25.12.07.05; author choi; state Exp; branches; next 2.23; 2.23 date 91.02.19.13.43.42; author choi; state Exp; branches; next 2.22; 2.22 date 91.02.19.13.04.39; author choi; state Exp; branches; next 2.21; 2.21 date 91.02.18.19.26.52; author choi; state Exp; branches; next 2.20; 2.20 date 91.02.09.04.53.32; author choi; state Exp; branches; next 2.19; 2.19 date 91.02.04.15.16.49; author kemnitz; state Exp; branches; next 2.18; 2.18 date 91.02.02.18.26.27; author mao; state Exp; branches; next 2.17; 2.17 date 91.02.01.15.24.17; author mao; state Exp; branches; next 2.16; 2.16 date 91.01.29.13.56.48; author mao; state Exp; branches; next 2.15; 2.15 date 91.01.21.11.39.58; author sp; state Exp; branches; next 2.14; 2.14 date 91.01.17.19.01.09; author sp; state Exp; branches; next 2.13; 2.13 date 91.01.09.19.02.27; author sp; state Exp; branches; next 2.12; 2.12 date 90.10.27.17.05.51; author kemnitz; state Exp; branches; next 2.11; 2.11 date 90.10.26.23.50.22; author kemnitz; state Exp; branches; next 2.10; 2.10 date 90.10.26.11.45.23; author choi; state Exp; branches; next 2.9; 2.9 date 90.10.24.12.04.01; author choi; state Exp; branches; next 2.8; 2.8 date 90.10.23.12.17.32; author goh; state Exp; branches; next 2.7; 2.7 date 90.10.22.16.22.40; author goh; state Exp; branches; next 2.6; 2.6 date 90.10.19.11.22.22; author goh; state Exp; branches; next 2.5; 2.5 date 90.10.18.20.21.18; author goh; state Exp; branches; next 2.4; 2.4 date 90.10.10.18.51.48; author hong; state Exp; branches; next 2.3; 2.3 date 90.10.01.16.15.19; author choi; state Exp; branches; next 2.2; 2.2 date 90.09.20.11.29.01; author goh; state Exp; branches; next 2.1; 2.1 date 90.09.20.10.15.41; author goh; state Exp; branches; next 2.0; 2.0 date 90.09.18.12.54.34; author goh; state Exp; branches; next 1.100; 1.100 date 90.09.04.14.32.53; author choi; state Exp; branches; next 1.99; 1.99 date 90.09.04.13.52.35; author goh; state Exp; branches; next 1.98; 1.98 date 90.08.17.12.28.03; author choi; state Exp; branches; next 1.97; 1.97 date 90.08.17.11.40.30; author cimarron; state Exp; branches; next 1.96; 1.96 date 90.08.17.11.27.36; author ong; state Exp; branches; next 1.95; 1.95 date 90.08.03.16.38.40; author choi; state Exp; branches; next 1.94; 1.94 date 90.08.03.13.02.48; author choi; state Exp; branches; next 1.93; 1.93 date 90.08.01.17.24.07; author choi; state Exp; branches; next 1.92; 1.92 date 90.08.01.16.03.12; author choi; state Exp; branches; next 1.91; 1.91 date 90.07.31.12.33.34; author choi; state Exp; branches; next 1.90; 1.90 date 90.07.30.17.55.08; author sp; state Version_2; branches; next 1.89; 1.89 date 90.07.30.12.04.33; author sp; state Exp; branches; next 1.88; 1.88 date 90.07.20.10.57.35; author goh; state Exp; branches; next 1.87; 1.87 date 90.07.19.12.46.02; author goh; state Exp; branches; next 1.86; 1.86 date 90.07.18.15.24.33; author goh; state Exp; branches; next 1.85; 1.85 date 90.07.17.16.18.49; author goh; state Exp; branches; next 1.84; 1.84 date 90.07.17.10.33.09; author goh; state Exp; branches; next 1.83; 1.83 date 90.07.14.14.04.00; author goh; state Exp; branches; next 1.82; 1.82 date 90.07.14.10.38.47; author goh; state Exp; branches; next 1.81; 1.81 date 90.07.14.10.32.12; author goh; state Exp; branches; next 1.80; 1.80 date 90.07.13.15.24.06; author goh; state Exp; branches; next 1.79; 1.79 date 90.07.13.13.19.59; author goh; state Exp; branches; next 1.78; 1.78 date 90.07.12.21.27.52; author goh; state Exp; branches; next 1.77; 1.77 date 90.07.12.21.14.22; author goh; state Exp; branches; next 1.76; 1.76 date 90.07.12.12.11.56; author goh; state Exp; branches; next 1.75; 1.75 date 90.07.12.11.45.27; author goh; state Exp; branches; next 1.74; 1.74 date 90.07.11.13.20.51; author goh; state Exp; branches; next 1.73; 1.73 date 90.07.10.12.52.36; author goh; state Exp; branches; next 1.72; 1.72 date 90.05.25.13.36.35; author mao; state Exp; branches; next 1.71; 1.71 date 90.05.21.00.20.21; author kemnitz; state Exp; branches; next 1.70; 1.70 date 90.05.20.21.25.09; author kemnitz; state Exp; branches; next 1.69; 1.69 date 90.05.18.00.22.50; author goh; state Exp; branches; next 1.68; 1.68 date 90.05.14.15.41.20; author goh; state Exp; branches; next 1.67; 1.67 date 90.05.14.15.20.53; author goh; state Exp; branches; next 1.66; 1.66 date 90.05.14.15.19.03; author goh; state Exp; branches; next 1.65; 1.65 date 90.05.14.14.46.41; author goh; state Exp; branches; next 1.64; 1.64 date 90.04.22.15.10.40; author mao; state Exp; branches; next 1.63; 1.63 date 90.04.17.21.25.48; author goh; state Exp; branches; next 1.62; 1.62 date 90.04.13.13.09.22; author goh; state Exp; branches; next 1.61; 1.61 date 90.04.12.23.29.32; author goh; state Exp; branches; next 1.60; 1.60 date 90.04.12.22.05.59; author goh; state Exp; branches; next 1.59; 1.59 date 90.03.14.10.46.33; author goh; state Exp; branches; next 1.58; 1.58 date 90.03.13.18.32.04; author goh; state Exp; branches; next 1.57; 1.57 date 90.03.13.18.16.08; author goh; state Exp; branches; next 1.56; 1.56 date 90.03.12.13.51.59; author goh; state Exp; branches; next 1.55; 1.55 date 89.09.21.18.48.57; author hirohama; state Exp; branches; next 1.54; 1.54 date 89.09.19.10.57.33; author goh; state Exp; branches; next 1.53; 1.53 date 89.09.15.16.21.30; author hirohama; state Exp; branches; next 1.52; 1.52 date 89.09.15.11.49.25; author goh; state Exp; branches; next 1.51; 1.51 date 89.09.15.11.40.42; author goh; state Exp; branches; next 1.50; 1.50 date 89.09.15.11.18.14; author goh; state Exp; branches; next 1.49; 1.49 date 89.09.14.17.55.46; author goh; state Exp; branches; next 1.48; 1.48 date 89.09.10.18.46.02; author hirohama; state Exp; branches; next 1.47; 1.47 date 89.09.10.17.10.27; author hirohama; state Exp; branches; next 1.46; 1.46 date 89.09.05.16.51.15; author mao; state C_Demo_1; branches; next 1.45; 1.45 date 89.08.31.14.15.02; author goh; state Exp; branches; next 1.44; 1.44 date 89.08.31.11.04.18; author goh; state Exp; branches; next 1.43; 1.43 date 89.08.31.10.48.02; author goh; state Exp; branches; next 1.42; 1.42 date 89.08.29.17.36.40; author hirohama; state Exp; branches; next 1.41; 1.41 date 89.08.29.13.10.57; author hirohama; state Exp; branches; next 1.40; 1.40 date 89.08.28.18.38.32; author hirohama; state Exp; branches; next 1.39; 1.39 date 89.08.25.11.13.12; author goh; state Exp; branches; next 1.38; 1.38 date 89.08.22.18.23.30; author hirohama; state Exp; branches; next 1.36; 1.36 date 89.08.22.15.55.48; author hirohama; state Exp; branches; next 1.35; 1.35 date 89.08.18.12.14.34; author hirohama; state Exp; branches; next 1.34; 1.34 date 89.08.16.20.37.27; author hirohama; state Exp; branches; next 1.33; 1.33 date 89.08.14.11.37.08; author goh; state Exp; branches; next 1.32; 1.32 date 89.08.04.13.16.32; author goh; state Exp; branches; next 1.31; 1.31 date 89.07.31.11.43.40; author goh; state Exp; branches; next 1.30; 1.30 date 89.07.25.16.49.58; author goh; state Exp; branches; next 1.29; 1.29 date 89.07.25.13.06.25; author goh; state Exp; branches; next 1.28; 1.28 date 89.03.31.02.26.40; author hirohama; state Stab; branches; next 1.27; 1.27 date 89.03.30.18.14.45; author goh; state Exp; branches; next 1.26; 1.26 date 89.03.27.14.00.12; author goh; state Exp; branches; next 1.25; 1.25 date 89.03.26.20.16.01; author goh; state Exp; branches; next 1.24; 1.24 date 89.03.26.00.06.29; author goh; state Exp; branches; next 1.23; 1.23 date 89.03.25.01.36.53; author goh; state Exp; branches; next 1.22; 1.22 date 89.03.24.10.32.37; author goh; state Exp; branches; next 1.21; 1.21 date 89.03.24.10.27.25; author goh; state Exp; branches; next 1.20; 1.20 date 89.03.22.15.06.16; author goh; state Exp; branches; next 1.19; 1.19 date 89.03.22.10.12.47; author goh; state Exp; branches; next 1.18; 1.18 date 89.03.20.19.58.10; author goh; state Exp; branches; next 1.17; 1.17 date 89.03.20.19.26.31; author goh; state Exp; branches; next 1.16; 1.16 date 89.03.20.19.06.35; author goh; state Exp; branches; next 1.15; 1.15 date 89.03.20.17.18.07; author goh; state Exp; branches; next 1.14; 1.14 date 89.03.20.15.52.03; author goh; state Exp; branches; next 1.13; 1.13 date 89.03.20.11.26.14; author goh; state Exp; branches; next 1.12; 1.12 date 89.03.17.20.05.33; author goh; state Exp; branches; next 1.11; 1.11 date 89.03.14.13.43.52; author hirohama; state Exp; branches; next 1.10; 1.10 date 89.03.14.13.19.20; author hirohama; state Exp; branches; next 1.9; 1.9 date 89.03.13.21.42.48; author goh; state Exp; branches; next 1.8; 1.8 date 89.03.09.21.14.23; author hirohama; state Exp; branches; next 1.7; 1.7 date 89.03.07.17.43.28; author goh; state Exp; branches; next 1.6; 1.6 date 89.03.07.16.08.02; author goh; state Exp; branches; next 1.5; 1.5 date 89.03.07.01.18.48; author goh; state Exp; branches; next 1.4; 1.4 date 89.03.06.14.28.13; author hirohama; state Exp; branches; next 1.3; 1.3 date 89.03.02.01.55.17; author goh; state Exp; branches; next 1.2; 1.2 date 89.03.02.00.52.52; author goh; state Exp; branches; next 1.1; 1.1 date 89.02.22.16.12.30; author goh; state Exp; branches; next ; desc @@ 4.16 log @turn off async portals for 4.0.1 @ text @%{ #define YYDEBUG 1 /********************************************************************** $Header: /private/mer/pg/src/parser/RCS/gram.y,v 4.15 1992/08/25 17:49:04 mer Exp mer $ POSTGRES YACC rules/actions Conventions used in coding this YACC file: CAPITALS are used to represent terminal symbols. non-capitals are used to represent non-terminals. **********************************************************************/ #include #include #include "tmp/c.h" #include "catalog_utils.h" #include "catalog/catname.h" #include "catalog/pg_log.h" #include "catalog/pg_magic.h" #include "catalog/pg_time.h" #include "catalog/pg_variable.h" #include "access/heapam.h" #include "utils/log.h" #include "utils/palloc.h" #include "nodes/pg_lisp.h" /* XXX ORDER DEPENDENCY */ #include "parse_query.h" #include "nodes/primnodes.h" #include "nodes/primnodes.a.h" #include "rules/params.h" #include "utils/lsyscache.h" extern LispValue new_filestr(); extern LispValue parser_typecast(); extern LispValue make_targetlist_expr(); extern List MakeList(); extern List FlattenRelationList(); extern List ParseAgg(); extern LispValue make_array_ref(); #define ELEMENT yyval = nappend1( LispNil , yypvt[-0] ) #define INC_LIST yyval = nappend1( yypvt[-2] , yypvt[-0] ) /* $1,$3 */ #define NULLTREE yyval = LispNil ; #define LAST(lv) lispCons ( lv , LispNil ) #define INC_NUM_LEVELS(x) { if (NumLevels < x ) NumLevels = x; } #define KW(keyword) lispAtom(CppAsString(keyword)) #define ADD_TO_RT(rt_entry) p_rtable = nappend1(p_rtable,rt_entry) #define YYSTYPE LispValue extern YYSTYPE parsetree; LispValue NewOrCurrentIsReally = (LispValue)NULL; bool ResdomNoIsAttrNo = false; extern YYSTYPE parser_ppreserve(); static YYSTYPE temp; int NumLevels = 0; YYSTYPE yylval; YYSTYPE p_target, p_qual, p_root, p_priority, p_ruleinfo; YYSTYPE p_rtable, p_target_resnos; static int p_numlevels,p_last_resno; Relation parser_current_rel = NULL; static bool QueryIsRule = false; bool Input_is_string = false; bool Input_is_integer = false; bool Typecast_ok = true; %} /* Commands */ %token ABORT_TRANS ADD_ATTR APPEND ATTACH_AS BEGIN_TRANS CLOSE CLUSTER COPY CREATE DEFINE DELETE DESTROY END_TRANS EXECUTE FETCH MERGE MOVE PURGE REMOVE RENAME REPLACE RETRIEVE /* Keywords */ %token ALL ALWAYS AFTER AND ARCHIVE ARCH_STORE ARG ASCENDING BACKWARD BEFORE BINARY BY DEMAND DESCENDING EMPTY FORWARD FROM HEAVY INTERSECT INTO IN INDEX INDEXABLE INHERITS INPUTPROC IS KEY LEFTOUTER LIGHT STORE MERGE NEVER NEWVERSION NONE NONULLS NOT PNULL ON ONCE OR OUTPUTPROC PORTAL PRIORITY QUEL RIGHTOUTER RULE SCONST SETOF SORT TO TRANSACTION UNION UNIQUE USING WHERE WITH FUNCTION OPERATOR P_TYPE /* Special keywords */ %token IDENT SCONST ICONST Op CCONST FCONST /* add tokens here */ %token INHERITANCE VERSION CURRENT NEW THEN DO INSTEAD VIEW REWRITE P_TUPLE TYPECAST P_FUNCTION C_FUNCTION C_FN POSTQUEL RELATION RETURNS INTOTEMP LOAD CREATEDB DESTROYDB STDIN STDOUT VACUUM PARALLEL AGGREGATE NOTIFY LISTEN IPORTAL ISNULL NOTNULL /* precedence */ %left OR %left AND %right NOT %right '=' %nonassoc Op %nonassoc NOTNULL %nonassoc ISNULL %left '+' '-' %left '*' '/' %left '|' /* this is the relation union op, not logical or */ %right ';' ':' /* Unary Operators */ %nonassoc '<' '>' %right UMINUS %left '.' %left '[' ']' %nonassoc TYPECAST %nonassoc REDUCE %token PARAM AS %% queryblock: query { parser_init(param_type_info, pfunc_num_args); } queryblock { parsetree = lispCons ( $1 , parsetree ) ; } | query { parsetree = lispCons($1,LispNil) ; parser_init(param_type_info, pfunc_num_args); } ; query: stmt | PARALLEL ICONST stmt { $$ = nappend1($3, $2); } ; stmt : AttributeAddStmt | ATTACH_AS attach_args /* what are the args ? */ | AggregateStmt | ClosePortalStmt | ClusterStmt | CopyStmt | CreateStmt | DefineStmt | DestroyStmt | FetchStmt | IndexStmt | MergeStmt | MoveStmt | ListenStmt | ProcedureStmt | PurgeStmt | RemoveOperatorStmt | RemoveStmt | RenameStmt | OptimizableStmt | RuleStmt | TransactionStmt | ViewStmt | LoadStmt | CreatedbStmt | DestroydbStmt | VacuumStmt ; /********************************************************************** QUERY : addattr ( attr1 = type1 .. attrn = typen ) to TREE : (ADD_ATTR (attr1 type1) . . (attrn typen) ) **********************************************************************/ AttributeAddStmt: ADD_ATTR '(' var_defs ')' TO relation_name { $$ = lispCons( $6 , $3); $$ = lispCons( KW(addattr) , $$); } ; /********************************************************************** QUERY : close TREE : (CLOSE ) **********************************************************************/ ClosePortalStmt: CLOSE opt_id { $$ = MakeList ( KW(close), $2, -1 ); } ; /********************************************************************** QUERY : cluster on [using ] TREE: XXX ??? unimplemented as of 1/8/89 **********************************************************************/ ClusterStmt: CLUSTER relation_name ON index_name OptUseOp { elog(WARN,"cluster statement unimplemented in version 2"); } ; /********************************************************************** QUERY : COPY [BINARY] [NONULLS] FROM/TO [USING ] TREE: ( COPY ("relname" [BINARY] [NONULLS] ) ( FROM/TO "filename") ( USING "maprelname") **********************************************************************/ CopyStmt: COPY copy_type copy_null relation_name copy_dirn copy_file_name copy_map { LispValue temp; $$ = lispCons( KW(copy), LispNil); $4 = lispCons($4,LispNil); $4 = nappend1($4,$2); $4 = nappend1($4,$3); $$ = nappend1($$,$4); $$ = nappend1($$,lispCons ($5,lispCons($6,LispNil))); if(! lispNullp($7)) $7 = lispCons($7,LispNil); $$ = nappend1($$, lispCons(KW(using), $7)); temp = $$; while(temp != LispNil && CDR(temp) != LispNil ) temp = CDR(temp); CDR(temp) = LispNil; } ; copy_dirn: TO { $$ = KW(to); } | FROM { $$ = KW(from); } ; copy_map: /*EMPTY*/ { NULLTREE } | Using map_rel_name { $$ = $2 ; } ; copy_null: /*EMPTY*/ { NULLTREE } | Nonulls ; copy_type: /*EMPTY*/ { NULLTREE } | BINARY { $$ = KW(binary); } ; /* create a relation */ CreateStmt: CREATE relation_name '(' opt_var_defs ')' OptKeyPhrase OptInherit OptIndexable OptArchiveType OptLocation OptArchiveLocation { LispValue temp = LispNil; $11 = lispCons ($11, LispNil); $10 = lispCons ($10, $11); $9 = lispCons ( $9, $10); $8 = lispCons ( $8, $9 ); $7 = lispCons ( $7, $8 ); $6 = lispCons ( $6, $7 ); $2 = lispCons ( $2, LispNil ); $$ = lispCons ( KW(create), $2 ); $$ = nappend1 ( $$, $6 ); temp = $$; while (CDR(temp) != LispNil) temp = CDR(temp); CDR(temp) = $4; } | CREATE OptDeltaDirn NEWVERSION relation_name FROM relation_name_version { $$ = MakeList ( $2, $4, $6,-1 ); } ; relation_name_version: relation_name | relation_name '[' date ']' { $$ = MakeList( $1, $3, -1); } ; OptDeltaDirn: /*EMPTY*/ { $$ = KW(forward);} | FORWARD { $$ = KW(forward); } | BACKWARD { $$ = KW(backward); } ; OptIndexable: /*EMPTY*/ { NULLTREE } | Indexable dom_name_list { $$ = lispCons ( $1 , $2 ); } ; dom_name_list: name_list; OptArchiveType: /*EMPTY*/ { NULLTREE } | ARCHIVE '=' archive_type { $$ = lispCons (KW(archive) , $3); } ; archive_type: HEAVY { $$ = KW(heavy); } | LIGHT { $$ = KW(light); } | NONE { $$ = KW(none); } ; OptLocation: /*EMPTY*/ { NULLTREE } | STORE '=' Sconst { int which; which = smgrin(LISPVALUE_STRING($3)); $$ = lispCons(KW(store), lispInteger(which)); } ; OptArchiveLocation: /*EMPTY*/ { NULLTREE } | ARCH_STORE '=' Sconst { int which; which = smgrin(LISPVALUE_STRING($3)); $$ = lispCons(KW(arch_store), lispInteger(which)); } ; OptInherit: /*EMPTY */ { NULLTREE } | INHERITS '(' relation_name_list ')' { $$ = lispCons ( KW(inherits), $3 ) ; } ; OptKeyPhrase : /* NULL */ { NULLTREE } | Key '(' key_list ')' { $$ = MakeList ( $1, $3, -1 ); } ; key_list: key { ELEMENT ; } | key_list ',' key { INC_LIST ; } ; key: attr_name OptUseOp { $$ = lispCons($1,lispCons($2,LispNil)) ; } ; /********************************************************************** QUERY : define (type,operator) TREE : **********************************************************************/ DefineStmt: DEFINE def_type def_rest { $2 = lispCons ($2 , $3 ); $$ = lispCons (KW(define) , $2 ); } ; def_rest: def_name definition opt_def_args { if ( $3 != LispNil ) $2 = nappend1 ($2, $3 ); $$ = lispCons ($1 , $2 ); } ; def_type: Operator | Type ; def_name: Id | Op | '+' { $$ = lispString("+"); } | '-' { $$ = lispString("-"); } | '*' { $$ = lispString("*"); } | '/' { $$ = lispString("/"); } | '<' { $$ = lispString("<"); } | '>' { $$ = lispString(">"); } | '=' { $$ = lispString("="); } ; opt_def_args: /* Because "define procedure .." */ ARG IS '(' def_name_list ')' { $$ = lispCons (KW(arg), $4); } | /*EMPTY*/ { NULLTREE } ; def_name_list: name_list; def_arg: Id | Op | NumConst | Sconst | SETOF Id { $$ = lispCons(KW(setof), $2); } ; definition: '(' def_list ')' { $$ = $2; } ; def_elem: def_name '=' def_arg { $$ = lispCons($1, lispCons($3, LispNil)); } | def_name { $$ = lispCons($1, LispNil); } ; def_list: def_elem { ELEMENT ; } | def_list ',' def_elem { INC_LIST ; } ; /********************************************************************** destroy [, .. ] ( DESTROY "relname1" ["relname2" .. "relnameN"] ) **********************************************************************/ DestroyStmt: DESTROY relation_name_list { $$ = lispCons( KW(destroy) ,$2) ; } ; /********************************************************************** QUERY: fetch [forward | backward] [number | all ] [ in ] TREE: (FETCH ) **********************************************************************/ FetchStmt: FETCH opt_direction fetch_how_many opt_portal_name { $$ = MakeList ( KW(fetch), $4, $2, $3, -1 ); } ; fetch_how_many: /*EMPTY, default is all*/ { $$ = KW(all) ; } | NumConst | ALL { $$ = KW(all) ; } ; /********************************************************************** QUERY: move [] [] [] TREE: ( MOVE ["portalname"] (TO | **********************************************************************/ MoveStmt: MOVE opt_direction opt_move_where opt_portal_name { $$ = MakeList ( KW(move), $4, $2, $3, -1 ); } ; opt_direction: /*EMPTY, by default forward */ { $$ = KW(forward); } | FORWARD { $$ = KW(forward); } | BACKWARD { $$ = KW(backward); } ; opt_move_where: /*EMPTY*/ { NULLTREE } | NumConst /* $$ = $1 */ | TO NumConst { $$ = MakeList ( KW(to), $2, -1 ); } | TO record_qual { $$ = lispString("record quals unimplemented") ; } ; opt_portal_name: /*EMPTY*/ { NULLTREE } | IN name { $$ = $2;} ; /************************************************************ define index: define [archive] index on using "(" ( with )+ ")" with ************************************************************/ IndexStmt: DEFINE opt_archive Index index_name ON relation_name Using access_method '(' index_params ')' with_clause where_clause { /* should check that access_method is valid, etc ... but doesn't */ $$ = MakeList ( $6,$4,$8,$10,$12,$13,-1 ); $$ = lispCons(KW(index),$$); $$ = lispCons(KW(define),$$); } ; /************************************************************ QUERY: merge into TREE: ( MERGE ) XXX - unsupported in version 3 (outside of parser) ************************************************************/ MergeStmt: MERGE relation_expr INTO relation_name { $$ = MakeList ( $1, $2, $4, -1 ); elog(WARN, "merge is unsupported in version 4"); } ; /************************************************************ QUERY: define function (language = , returntype = [, arch_pct = ] [, disk_pct = ] [, byte_pct = ] [, perbyte_cpu = ] [, percall_cpu = ] [, iscachable]) [arg is ( { , })] as ************************************************************/ ProcedureStmt: DEFINE FUNCTION def_rest AS SCONST { $$ = lispCons($5, LispNil); $$ = lispCons($3, $$); $$ = lispCons(KW(function), $$); $$ = lispCons(KW(define), $$); }; AggregateStmt: DEFINE AGGREGATE def_rest { $$ = lispCons( KW(aggregate), $3); $$ = lispCons( KW(define), $$); } ; /********************************************************************** Purge: purge [before ] [after ] or purge [after][before ] (PURGE "relname" ((BEFORE date)(AFTER date))) **********************************************************************/ PurgeStmt: PURGE relation_name purge_quals { $$ = lispCons ( $3, LispNil ); $$ = lispCons ( $2, $$ ); $$ = lispCons ( KW(purge), $$ ); } ; purge_quals: /*EMPTY*/ {$$=lispList();} | before_clause { $$ = lispCons ( $1, LispNil ); } | after_clause { $$ = lispCons ( $1, LispNil ); } | before_clause after_clause { $$ = MakeList ( $1, $2 , -1 ); } | after_clause before_clause { $$ = MakeList ( $2, $1, -1 ); } ; before_clause: BEFORE date { $$ = MakeList ( KW(before),$2,-1); } after_clause: AFTER date { $$ = MakeList ( KW(after),$2,-1 ); } /********************************************************************** Remove: remove function (REMOVE FUNCTION "funcname") remove operator (REMOVE OPERATOR ("opname" leftoperand_typ rightoperand_typ)) remove type (REMOVE TYPE "typename") remove rewrite rule (REMOVE REWRITE RULE "rulename") remove tuple rule (REMOVE RULE "rulename") **********************************************************************/ RemoveStmt: REMOVE remove_type name { $$ = MakeList ( KW(remove), $2, $3 , -1 ); } ; remove_type: Function | Aggregate | Type | Index | RuleType | VIEW ; RuleType: newruleTag RULE { /* * the rule type can be either * P_TYPE or REWRITE */ $$ = CAR($1); } ; RemoveOperatorStmt: REMOVE Operator Op '(' remove_operator ')' { $$ = lispCons($3, $5); $$ = lispCons($2, lispCons($$, LispNil)); $$ = lispCons( KW(remove) , $$); } | REMOVE Operator MathOp '(' remove_operator ')' { $$ = lispCons($3, $5); $$ = lispCons($2, lispCons($$, LispNil)); $$ = lispCons( KW(remove) , $$); } ; MathOp: | '+' { $$ = lispString("+"); } | '-' { $$ = lispString("-"); } | '*' { $$ = lispString("*"); } | '/' { $$ = lispString("/"); } | '<' { $$ = lispString("<"); } | '>' { $$ = lispString(">"); } | '=' { $$ = lispString("="); } ; remove_operator: name { $$ = lispCons($1, LispNil); } | name ',' name { $$ = MakeList ( $1, $3, -1 ); } ; /********************************************************************** rename in to ( RENAME "ATTRIBUTE" "relname" "attname1" "attname2" ) rename to ( RENAME "RELATION" "relname1" "relname2" ) **********************************************************************/ RenameStmt : RENAME attr_name IN relation_name TO attr_name { $$ = MakeList ( KW(rename), lispString("ATTRIBUTE"), $4, $2, $6, -1 ); } | RENAME relation_name TO relation_name { $$ = MakeList ( KW(rename), lispString("RELATION"), $2, $4, -1 ); } ; /* ADD : Define Rewrite Rule , Define Tuple Rule Define Rule */ opt_support: '[' NumConst ',' NumConst ']' { $$ = lispCons ( $2, $4 ); } | /* EMPTY */ { $$ = lispCons ( lispFloat(1.0), lispFloat(0.0) ); } ; RuleStmt: DEFINE newruleTag RULE name opt_support IS { p_ruleinfo = lispCons(lispInteger(0),LispNil); p_priority = lispInteger(0) ; } RuleBody { if ( CAtom(CAR($2))==P_TUPLE) { /* XXX - do the bogus fix to get param nodes to replace varnodes that have current in them */ /*==== XXX * LET THE TUPLE-LEVEL RULE MANAGER DO * THE SUBSTITUTION.... SubstituteParamForNewOrCurrent ( $8 ); *==== */ $$ = lispCons ( $8, lispCons ( p_rtable, NULL )); $$ = lispCons ( $4, $$ ); if (null(CDR($2))) { List t; t = lispCons(LispNil, LispNil); t = lispCons(KW(rule), t); $$ = lispCons(t, $$); } else { List t; t = lispCons(CADR($2), LispNil); t = lispCons(KW(rule), t); $$ = lispCons(t, $$); } $$ = lispCons ( CAR($2), $$ ); $$ = lispCons ( KW(define), $$ ); } else { $$ = nappend1 ( $8, $5 ); $$ = lispCons ( $4, $$ ); $$ = lispCons ( KW(rule), $$ ); $$ = lispCons ( CAR($2), $$ ); $$ = lispCons ( KW(define), $$ ); } } ; /*------------------------- * We currently support the following rule tags: * * 'tuple' i.e. a rule implemented with the tuple level rule system * 'rewrite' i.e. a rule implemented with the rewrite system * 'relation tuple' a rule implemented with the tuple level rule * system, but which is forced to use a relation * level lock (even if we could have used the * more efficient tuple-level rule lock). * This option is used for debugging... * 'tuple tuple' i.e. it must be implemented with a tuple level * lock. * * 25 feb 1991: stonebraker is objectifying our terminology. as a * result, 'tuples' no longer exist. they've been replaced * by 'instances'. we still use the old terminology inside * the system, but the visible interface has been changed. */ newruleTag: P_TUPLE { $$ = lispCons(KW(instance), LispNil); } | REWRITE { $$ = lispCons(KW(rewrite), LispNil); } | RELATION P_TUPLE { $$ = lispCons(KW(relation), LispNil); $$ = lispCons(KW(instance), $$); } | P_TUPLE P_TUPLE { $$ = lispCons(KW(instance), LispNil); $$ = lispCons(KW(instance), $$); } | /* EMPTY */ { $$ = lispCons(KW(instance), LispNil); } ; OptStmtList: Id { if ( ! strcmp(CString($1),"nothing") ) { $$ = LispNil; } else elog(WARN,"bad rule action %s", CString($1)); } | OptimizableStmt { $$ = lispCons ( $1, LispNil ); } | '[' OptStmtBlock ']' { $$ = $2; } ; OptStmtBlock: OptimizableStmt { ELEMENT ;} | OptStmtBlock { p_last_resno = 1; p_target_resnos = LispNil; p_target = LispNil; } OptimizableStmt { $$ = nappend1($1, $3); } ; RuleBody: ON event TO event_object { /* XXX - figure out how to add a from_clause into this rule thing properly. Spyros/Greg's bogus fix really breaks things, so I had to axe it. */ NewOrCurrentIsReally = $4; /* * NOTE: 'CURRENT' must always have a varno * equal to 1 and 'NEW' equal to 2. */ ADD_TO_RT ( MakeRangeTableEntry ( (Name)CString(CAR($4)), LispNil, (Name)"*CURRENT*" ) ); ADD_TO_RT ( MakeRangeTableEntry ( (Name)CString(CAR($4)), LispNil, (Name)"*NEW*" )); QueryIsRule = true; } where_clause DO opt_instead OptStmtList { $$ = MakeList ( $2, $4, $6, $8, $9, -1 ); /* modify the rangetable entry for "current" and "new" */ } ; event_object: relation_name '.' attr_name { $$ = MakeList ( $1, $3, -1 ); } | relation_name { $$ = lispCons ( $1, LispNil ); } ; event: RETRIEVE | REPLACE | DELETE | APPEND ; opt_instead: INSTEAD { $$ = lispInteger((int)true); } | /* EMPTY */ { $$ = lispInteger((int)false); } ; /* NOTIFY can appear both in rule bodies and as a query-level command */ NotifyStmt: NOTIFY relation_name { LispValue root; int x = 0; elog(WARN, "notify is turned off for 4.0.1 - see the release notes"); if((x=RangeTablePosn(CString($2),LispNil)) == 0 ) ADD_TO_RT (MakeRangeTableEntry ((Name)CString($2), LispNil, (Name)CString($2))); if (x==0) x = RangeTablePosn(CString($2),LispNil); parser_current_rel = heap_openr(VarnoGetRelname(x)); if (parser_current_rel == NULL) elog(WARN,"notify: relation %s doesn't exist",CString($2)); else heap_close(parser_current_rel); root = MakeRoot(1, KW(notify), lispInteger(x), /* result relation */ p_rtable, /* range table */ p_priority, /* priority */ p_ruleinfo, /* rule info */ LispNil, /* unique flag */ LispNil, /* sort clause */ LispNil); /* target list */ $$ = lispCons ( root , LispNil ); $$ = nappend1 ( $$ , LispNil ); /* */ $$ = nappend1 ( $$ , LispNil ); /* */ } ; ListenStmt: LISTEN relation_name { elog(WARN, "listen is turned off for 4.0.1 - see the release notes"); parser_current_rel = heap_openr(CString($2)); if (parser_current_rel == NULL) elog(WARN,"listen: relation %s doesn't exist",$2); else heap_close(parser_current_rel); $$ = MakeList(KW(listen),$2,-1); } ; /************************************************** Transactions: abort transaction (ABORT) begin transaction (BEGIN) end transaction (END) **************************************************/ TransactionStmt: ABORT_TRANS TRANSACTION { $$ = lispCons ( KW(abort), LispNil ) ; } | BEGIN_TRANS TRANSACTION { $$ = lispCons ( KW(begin), LispNil ) ; } | END_TRANS TRANSACTION { $$ = lispCons ( KW(end), LispNil ) ; } | ABORT_TRANS { $$ = lispCons ( KW(abort), LispNil ) ; } | BEGIN_TRANS { $$ = lispCons ( KW(begin), LispNil ) ; } | END_TRANS { $$ = lispCons ( KW(end), LispNil ) ; } ; /************************************************** View Stmt define view '('target-list ')' [where ] **************************************************/ ViewStmt: DEFINE VIEW name RetrieveSubStmt { $3 = lispCons ( $3 , $4 ); $2 = lispCons ( KW(view) , $3 ); $$ = lispCons ( KW(define) , $2 ); } ; /************************************************** Load Stmt load "filename" **************************************************/ LoadStmt: LOAD file_name { $$ = MakeList ( KW(load), $2, -1 ); } ; /************************************************** Createdb Stmt createdb dbname **************************************************/ CreatedbStmt: CREATEDB database_name { $$ = MakeList ( KW(createdb), $2, -1 ); } ; /************************************************** Destroydb Stmt destroydb dbname **************************************************/ DestroydbStmt: DESTROYDB database_name { $$ = MakeList ( KW(destroydb), $2, -1 ); } ; /************************************************** Vacuum Stmt vacuum **************************************************/ VacuumStmt: VACUUM { $$ = MakeList(KW(vacuum), -1); } ; /********************************************************************** ********************************************************************** Optimizable Stmts: one of the five queries processed by the planner [ultimately] produces query-trees as specified in the query-spec document in ~postgres/ref ********************************************************************** **********************************************************************/ OptimizableStmt: RetrieveStmt | ExecuteStmt | ReplaceStmt | AppendStmt | NotifyStmt | DeleteStmt /* by default all are $$=$1 */ ; /************************************************** AppendStmt - an optimizable statement, produces a querytree as per query spec **************************************************/ AppendStmt: APPEND { SkipForwardToFromList(); } from_clause opt_star relation_name { int x = 0; if((x=RangeTablePosn(CString($5),LispNil)) == 0) ADD_TO_RT( MakeRangeTableEntry((Name)CString($5), LispNil, (Name)CString($5))); if (x==0) x = RangeTablePosn(CString($5),LispNil); parser_current_rel = heap_openr(VarnoGetRelname(x)); if (parser_current_rel == NULL) elog(WARN,"invalid relation name"); ResdomNoIsAttrNo = true; } '(' res_target_list ')' where_clause { LispValue root; LispValue command; int x = RangeTablePosn(CString($5),LispNil); if ( $4 == LispNil ) command = KW(append); else command = lispCons( lispInteger('*'),KW(append)); root = MakeRoot(1, command , lispInteger(x), p_rtable, p_priority, p_ruleinfo, LispNil,LispNil,$8); $$ = lispCons ( root , LispNil ); $$ = nappend1 ( $$ , $8 ); /* (eq p_target $8) */ $$ = nappend1 ( $$ , $10 ); /* (eq p_qual $10 */ ResdomNoIsAttrNo = false; heap_close(parser_current_rel); } ; /************************************************** DeleteStmt - produces a querytree that looks like that in the query spec **************************************************/ DeleteStmt: DELETE { SkipForwardToFromList(); } from_clause opt_star var_name { int x = 0; if((x=RangeTablePosn(CString($5),LispNil)) == 0 ) ADD_TO_RT (MakeRangeTableEntry ((Name)CString($5), LispNil, (Name)CString($5))); if (x==0) x = RangeTablePosn(CString($5),LispNil); parser_current_rel = heap_openr(VarnoGetRelname(x)); if (parser_current_rel == NULL) elog(WARN,"invalid relation name"); else heap_close(parser_current_rel); /* ResdomNoIsAttrNo = true; */ } where_clause { LispValue root = LispNil; LispValue command = LispNil; int x = 0; x= RangeTablePosn(CString($5),LispNil); if (x == 0) ADD_TO_RT(MakeRangeTableEntry ((Name)CString ($5), LispNil, (Name)CString($5))); if ( $4 == LispNil ) command = KW(delete); else command = lispCons( lispInteger('*'),KW(delete)); root = MakeRoot(1,command, lispInteger ( x ) , p_rtable, p_priority, p_ruleinfo, LispNil,LispNil,LispNil); $$ = lispCons ( root , LispNil ); /* check that var_name is in the relation */ $$ = nappend1 ( $$ , LispNil ); /* no target list */ $$ = nappend1 ( $$ , $7 ); /* (eq p_qual $7 */ } ; /************************************************** ExecuteStmt - produces a querytree that looks like that in the queryspec **************************************************/ ExecuteStmt: EXECUTE opt_star opt_portal '(' res_target_list ')' from_clause with_clause where_clause { $$ = KW(execute); elog(WARN, "execute does not work in Version 1"); } ; /********************************************************************** Replace: - as per qtree specs **********************************************************************/ ReplaceStmt: REPLACE { SkipForwardToFromList(); } from_clause opt_star relation_name { int x = 0; if((x=RangeTablePosn(CString($5),LispNil) ) == 0 ) ADD_TO_RT( MakeRangeTableEntry ((Name)CString($5), LispNil, (Name)CString($5))); if (x==0) x = RangeTablePosn(CString($5),LispNil); parser_current_rel = heap_openr(VarnoGetRelname(x)); if (parser_current_rel == NULL) elog(WARN,"invalid relation name"); ResdomNoIsAttrNo = true; } '(' res_target_list ')' where_clause { LispValue root; LispValue command = LispNil; int result = RangeTablePosn(CString($5),LispNil); if (result < 1) elog(WARN,"parser internal error , bogus relation"); if ( $4 == LispNil ) command = KW(replace); else command = lispCons( lispInteger('*'),KW(replace)); root = MakeRoot(1, command , lispInteger(result), p_rtable, p_priority, p_ruleinfo, LispNil,LispNil,$8); $$ = lispCons( root , LispNil ); $$ = nappend1 ( $$ , $8 ); /* (eq p_target $6) */ $$ = nappend1 ( $$ , $10 ); /* (eq p_qual $9) */ ResdomNoIsAttrNo = false; heap_close(parser_current_rel); } ; /************************************************************ Retrieve: ( ( RETRIEVE ) (targetlist) (qualification) ) ************************************************************/ RetrieveStmt: RETRIEVE RetrieveSubStmt { $$ = $2 ; } ; RetrieveSubStmt: { SkipForwardToFromList(); } from_clause result opt_unique '(' res_target_list ')' where_clause ret_opt2 { /* XXX - what to do with opt_unique, from_clause */ LispValue root; LispValue command; command = KW(retrieve); root = MakeRoot(NumLevels,command, $3, p_rtable, p_priority, p_ruleinfo,$4,$9,$6); $$ = lispCons( root , LispNil ); $$ = nappend1 ( $$ , $6 ); $$ = nappend1 ( $$ , $8 ); } /************************************************** Retrieve result: into (INTO "relname"); portal (PORTAL "portname") NULL nil **************************************************/ result: INTO relation_name { $2=lispCons($2 , LispNil ); /* should check for archive level */ $$=lispCons(KW(into), $2); } | opt_portal /* takes care of the null case too */ ; opt_unique: /*EMPTY*/ { NULLTREE } | UNIQUE { $$ = KW(unique); } ; ret_opt2: /*EMPTY*/ { NULLTREE } | Sort BY sortby_list { $$ = $3 ; } ; sortby_list: sortby { ELEMENT ; } | sortby_list ',' sortby { INC_LIST ; } ; sortby: Id OptUseOp { $$ = lispCons ( $1, lispCons ($2, LispNil )) ; } | attr OptUseOp { /* i had to do this since a bug in yacc wouldn't catch */ /* this syntax error - ron choi 4/11/91 */ yyerror("syntax error: use \"sort by attribute_name\""); } ; opt_archive: { NULLTREE } | ARCHIVE { $$ = KW(archive); } ; index_params: index_list /* $$=$1 */ | func_index { ELEMENT ; } ; index_list: index_list ',' index_elem { INC_LIST ; } | index_elem { ELEMENT ; } ; func_index: ind_function opt_class { $$ = nappend1(LispNil,$1); nappend1($$,$2); } ; ind_function: name '(' name_list ')' { $$ = nappend1(LispNil,$1); rplacd($$,$3); } ; index_elem: attr_name opt_class { $$ = nappend1(LispNil,$1); nappend1($$,$2);} ; opt_class: /* empty */ { NULLTREE; } | class | With class {$$=$2;} ; /* * jimmy bell-style recursive queries aren't supported in the * current system. */ opt_star: /*EMPTY*/ { NULLTREE } ; relation_name_list: name_list ; name_list: name { ELEMENT ; } | name_list ',' name { INC_LIST ; } ; /********************************************************************** clauses common to all Optimizable Stmts: from_clause - where_clause - **********************************************************************/ with_clause: /* NULL */ { NULLTREE } | With '(' param_list ')' { $$ = MakeList ( $1,$3,-1 ); } ; param_list: param_list ',' param { INC_LIST ; } | param { ELEMENT ; } ; param: Id '=' string { $$ = MakeList ( $1, $3, -1 ); } ; from_clause: FROM from_list { $$ = $2 ; SkipBackToTlist(); yychar = -1; /* goto yynewstate; */ } | /*empty*/ { NULLTREE ; } ; from_list: from_list ',' from_val { INC_LIST ; } | from_val { ELEMENT ; } ; from_val: var_list IN relation_expr { extern List MakeFromClause (); $$ = MakeFromClause ( $1, $3 ); } ; var_list: var_list ',' var_name { INC_LIST ; } | var_name { ELEMENT ; } ; where_clause: /* empty - no qualifiers */ { NULLTREE } | WHERE a_expr { if (CInteger(CAR($2)) != BOOLOID) elog(WARN, "where clause must return type bool, not %s", tname(get_id_type(CInteger(CAR($2))))); p_qual = $$ = CDR($2); } ; opt_portal: /* common to retrieve, execute */ /*EMPTY*/ { NULLTREE } | IPORTAL name { /* * 15 august 1991 -- since 3.0 postgres does locking * right, we discovered that portals were violating * locking protocol. portal locks cannot span xacts. * as a short-term fix, we installed the check here. * -- mao */ if (!IsTransactionBlock()) elog(WARN, "Named portals may only be used in begin/end transaction blocks."); $$ = MakeList ( KW(iportal), $2, -1 ); } | PORTAL name { /* * 15 august 1991 -- since 3.0 postgres does locking * right, we discovered that portals were violating * locking protocol. portal locks cannot span xacts. * as a short-term fix, we installed the check here. * -- mao */ if (!IsTransactionBlock()) elog(WARN, "Named portals may only be used in begin/end transaction blocks."); $$ = MakeList ( KW(portal), $2, -1 ); } ; OptUseOp: /*EMPTY*/ { NULLTREE } | USING Op { $$ = $2; } | USING '<' { $$ = lispString("<"); } | USING '>' { $$ = lispString(">"); } ; relation_expr: relation_name { /* normal relations */ $$ = lispCons ( MakeList ( $1, LispNil , LispNil , -1 ), LispNil ); } | relation_expr '|' relation_expr %prec '=' { /* union'ed relations */ elog ( DEBUG, "now consing the union'ed relations"); $$ = append ( $1, $3 ); } | relation_name '*' %prec '=' { /* inheiritance query */ $$ = lispCons ( MakeList ( $1, LispNil, lispString("*"), -1) , LispNil ); } | relation_name time_range { /* time-qualified query */ $$ = lispCons ( MakeList ( $1, $2, LispNil , -1 ) , LispNil ); } | '(' relation_expr ')' { elog( DEBUG, "now reducing by parentheses"); $$ = $2; } ; time_range: '[' opt_range_start ',' opt_range_end ']' { $$ = MakeList ( $2, $4, lispInteger(1), -1 ); } | '[' date ']' { $$ = MakeList ( $2 , LispNil, lispInteger(0), -1 ); } ; opt_range_start: /* no date, default to nil */ { $$ = lispString("epoch"); } | date ; opt_range_end: /* no date, default to nil */ { $$ = lispString("now"); } | date ; record_qual: /*EMPTY*/ { NULLTREE } ; /* * Array bounds -- support for arrays in the current system is poor. * We'd like to support multi-dimensional arrays, arrays with lower * bounds at values other than 1, ..., but we don't. The only thing * that's real in the Array nodes we return below is arrayhigh, * which is the upper bound of the array. */ opt_array_bounds: '[' ']' { $$ = (LispValue) MakeArray((ObjectId) 0, 0, false, 0, -1, /* -1 means var length */ 0); } | '[' Iconst ']' { $$ = (LispValue) MakeArray((ObjectId) 0, 0, false, 0, CInteger($2), 0); } | /* EMPTY */ { NULLTREE } ; Typename: name opt_array_bounds { $$ = lispCons($1,$2); } ; var_def: Id '=' Typename { ObjectId typrelid; /* for 4.0, attributes cannot have complex types */ typrelid = get_typrelid(type(CString(CAR($3)))); if (typrelid != InvalidObjectId) { elog(NOTICE, "cannot create attribute of type %s", CString(CAR($3))); elog(WARN, "use functions to get complex objects"); } $$ = MakeList($1,$3,-1); } ; var_defs: var_defs ',' var_def { INC_LIST ; } | var_def { ELEMENT ; } ; opt_var_defs: var_defs | {NULLTREE} ; agg_where_clause: /* empty list */ {NULLTREE; } | WHERE a_expr { if (CInteger(CAR($2)) != BOOLOID) elog(WARN, "where clause must return type bool, not %s", tname(get_id_type(CInteger(CAR($2))))); $$ = CDR($2); } ; /* * expression grammar, still needs some cleanup */ a_expr: attr opt_indirection { List temp; temp = HandleNestedDots($1); if ($2 == LispNil) $$ = temp; else $$ = make_array_ref(temp, $2); Typecast_ok = false; } | AexprConst | '-' a_expr %prec UMINUS { $$ = make_op(lispString("-"), LispNil, $2, 'l'); Typecast_ok = false; } | a_expr '+' a_expr { $$ = make_op (lispString("+"), $1, $3, 'b' ) ; Typecast_ok = false; } | a_expr '-' a_expr { $$ = make_op (lispString("-"), $1, $3, 'b' ) ; Typecast_ok = false; } | a_expr '/' a_expr { $$ = make_op (lispString("/"), $1, $3, 'b' ) ; Typecast_ok = false; } | a_expr '*' a_expr { $$ = make_op (lispString("*"), $1, $3, 'b' ) ; Typecast_ok = false; } | a_expr '<' a_expr { $$ = make_op (lispString("<"), $1, $3, 'b' ) ; Typecast_ok = false; } | a_expr '>' a_expr { $$ = make_op (lispString(">"), $1, $3, 'b' ) ; Typecast_ok = false; } | a_expr '=' a_expr { $$ = make_op (lispString("="), $1, $3, 'b' ) ; Typecast_ok = false; } | ':' a_expr { $$ = make_op (lispString(":"), LispNil, $2, 'l' ) ; Typecast_ok = false; } | ';' a_expr { $$ = make_op (lispString(";"), LispNil, $2, 'l' ) ; Typecast_ok = false; } | '|' a_expr { $$ = make_op (lispString("|"), LispNil, $2, 'l' ) ; Typecast_ok = false; } | AexprConst TYPECAST Typename { extern LispValue parser_typecast(); $$ = parser_typecast ( $1, $3 ); Typecast_ok = false; /* it's already typecasted */ /* don't do it again. */ } | '(' a_expr ')' {$$ = $2;} | a_expr Op a_expr { $$ = make_op ( $2, $1 , $3, 'b' ); Typecast_ok = false; } | Op a_expr { $$ = make_op ( $1, LispNil, $2, 'l'); Typecast_ok = false; } | a_expr Op { $$ = make_op ( $2, $1, LispNil, 'r'); Typecast_ok = false; } | relation_name { $$ = lispCons ( KW(relation), $1 ); INC_NUM_LEVELS(1); Typecast_ok = false; } | name '(' ')' { extern List ParseFunc(); $$ = ParseFunc ( CString ( $1 ), LispNil ); Typecast_ok = false; } | name '(' expr_list ')' { extern List ParseFunc(); $$ = ParseFunc ( CString ( $1 ), $3 ); Typecast_ok = false; } | a_expr ISNULL { extern List ParseFunc(); yyval = nappend1( LispNil, $1); $$ = ParseFunc( "NullValue", yyval ); Typecast_ok = false; } | a_expr NOTNULL { extern List ParseFunc(); yyval = nappend1( LispNil, $1); $$ = ParseFunc( "NonNullValue", yyval ); Typecast_ok = false; } | a_expr AND a_expr { if (CInteger(CAR($1)) != BOOLOID) elog(WARN, "left-hand side of AND is type '%s', not bool", tname(get_id_type(CInteger(CAR($1))))); if (CInteger(CAR($3)) != BOOLOID) elog(WARN, "right-hand side of AND is type '%s', not bool", tname(get_id_type(CInteger(CAR($3))))); $$ = lispCons(lispInteger(BOOLOID), MakeList (lispInteger(AND), CDR($1), CDR($3), -1)); } | a_expr OR a_expr { if (CInteger(CAR($1)) != BOOLOID) elog(WARN, "left-hand side of OR is type '%s', not bool", tname(get_id_type(CInteger(CAR($1))))); if (CInteger(CAR($3)) != BOOLOID) elog(WARN, "right-hand side of OR is type '%s', not bool", tname(get_id_type(CInteger(CAR($3))))); $$ = lispCons(lispInteger(BOOLOID), MakeList (lispInteger(OR), CDR($1), CDR($3), -1)); } | NOT a_expr { if (CInteger(CAR($2)) != BOOLOID) elog(WARN, "argument to NOT is type '%s', not bool", tname(get_id_type(CInteger(CAR($2))))); $$ = lispCons(lispInteger(BOOLOID), MakeList (lispInteger(NOT), CDR($2), -1)); } ; /* we support only single-dim arrays in the current system */ opt_indirection: '[' a_expr ']' { if (CInteger(CAR($2)) != INT4OID) elog(WARN, "array index expressions must be int4's"); $$ = $2; } | /* EMPTY */ { NULLTREE } ; expr_list: a_expr { ELEMENT ; } | expr_list ',' a_expr { INC_LIST ; } ; attr: relation_name '.' attrs { INC_NUM_LEVELS(1); $$ = lispCons($1,$3); } | ParamNo '.' attrs { INC_NUM_LEVELS(1); $$ = lispCons($1,$3); } ; attrs: attr_name { $$ = lispCons($1, LispNil); } | attrs '.' attr_name { $$ = nappend1($1, $3);} agg_res_target_el: attr { LispValue varnode, temp; Resdom resnode; int type_id, type_len; temp = HandleNestedDots($1); type_id = CInteger(CAR(temp)); if (ISCOMPLEX(type_id)) elog(WARN, "Cannot use complex type %s as atomic value in target list", tname(get_id_type(type_id))); type_len = tlen(get_id_type(type_id)); resnode = MakeResdom ( (AttributeNumber)1, (ObjectId)type_id, ISCOMPLEX(type_id), (Size)type_len, (Name)CString(CAR(last ($1) )), (Index)0 , (OperatorTupleForm)0 , 0 ); varnode = CDR(temp); $$ = lispCons((LispValue)resnode, lispCons(varnode,LispNil)); } agg: name '{' agg_res_target_el agg_where_clause '}' { LispValue query2; LispValue varnode = $3; $3 = lispCons($3, LispNil); query2 = MakeRoot(1, KW(retrieve), LispNil, p_rtable, p_priority, p_ruleinfo, LispNil, LispNil,$3); query2 = lispCons (query2, LispNil); query2 = nappend1 (query2, $3); query2 = nappend1 (query2, $4); /* query2 now retrieves the subquery within the * agg brackets. * this will be the agg node's outer child. */ $$ = ParseAgg(CString($1), query2, varnode); /*paramlist = search_quals($4, aggnode);*/ /*$$ = nappend1($$, $4);*/ /* (rettype, "agg",aggname, query, tlist, -1) */ } res_target_list: res_target_list ',' res_target_el { p_target = nappend1(p_target,$3); $$ = p_target; } | res_target_el { p_target = lispCons ($1,LispNil); $$ = p_target;} | relation_name '.' ALL { LispValue temp = p_target; INC_NUM_LEVELS(1); if(temp == LispNil ) p_target = ExpandAll((Name)CString($1), &p_last_resno); else { while (temp != LispNil && CDR(temp) != LispNil) temp = CDR(temp); CDR(temp) = ExpandAll( (Name)CString($1), &p_last_resno); } $$ = p_target; } | res_target_list ',' relation_name '.' ALL { LispValue temp = p_target; if (ResdomNoIsAttrNo == true) { elog(WARN,"all doesn't make any sense here"); return(1); } INC_NUM_LEVELS(1); if(temp == LispNil ) p_target = ExpandAll((Name)CString($3), &p_last_resno); else { while(temp != LispNil && CDR(temp) != LispNil ) temp = CDR(temp); CDR(temp) = ExpandAll( (Name)CString($3), &p_last_resno); } $$ = p_target; } ; res_target_el: Id '=' agg { int type_id; int resdomno, type_len; List temp = LispNil; type_id = CInteger(CAR($3)); if (ISCOMPLEX(type_id)) elog(WARN, "Cannot assign complex type to variable %s in target list", CString($1)); type_len = tlen(get_id_type(type_id)); resdomno = p_last_resno++; temp = lispCons ((LispValue)MakeResdom((AttributeNumber)resdomno, (ObjectId)type_id, ISCOMPLEX(type_id), (Size)type_len, (Name)CString($1), (Index)0, (OperatorTupleForm)0, 0) , lispCons(CDR($3), LispNil) ); $$ = temp; } | Id '=' a_expr { if ($3 != LispNil && ISCOMPLEX(CInteger(CAR($3)))) elog(WARN, "Cannot assign complex type to variable %s in target list", CString($1)); $$ = make_targetlist_expr ($1,$3); } | attr opt_indirection { LispValue varnode, temp; Resdom resnode; int type_id, type_len; temp = HandleNestedDots($1); if ($2 != LispNil) temp = make_array_ref(temp, $2); type_id = CInteger(CAR(temp)); if (ISCOMPLEX(type_id)) elog(WARN, "Cannot use complex type %s as atomic value in target list", tname(get_id_type(type_id))); type_len = tlen(get_id_type(type_id)); resnode = MakeResdom ( (AttributeNumber)p_last_resno++ , (ObjectId)type_id, ISCOMPLEX(type_id), (Size)type_len, (Name)CString(CAR(last ($1) )), (Index)0 , (OperatorTupleForm)0, 0 ); varnode = CDR(temp); $$=lispCons((LispValue)resnode, lispCons(varnode,LispNil)); } ; opt_id: /*EMPTY*/ { NULLTREE } | Id ; relation_name: SpecialRuleRelation | Id { /* disallow refs to magic system tables */ if (strncmp(CString($1), Name_pg_log, 16) == 0 || strncmp(CString($1), Name_pg_variable, 16) == 0 || strncmp(CString($1), Name_pg_time, 16) == 0 || strncmp(CString($1), Name_pg_magic, 16) == 0) elog(WARN, "%s cannot be accessed by users", CString($1)); else $$ = $1; } ; database_name: Id /*$$=$1*/; access_method: Id /*$$=$1*/; attr_name: Id /*$$=$1*/; class: Id /*$$=$1*/; index_name: Id /*$$=$1*/; map_rel_name: Id /*$$=$1*/; var_name: Id /*$$=$1*/; name: Id /*$$-$1*/; string: Id /*$$=$1 Sconst ?*/; date: Sconst /*$$=$1*/; file_name: SCONST {$$ = new_filestr($1); }; copy_file_name: SCONST {$$ = new_filestr($1); }; | STDIN { $$ = lispString(CppAsString(stdin)); } | STDOUT { $$ = lispString(CppAsString(stdout)); } /* adt_const: Sconst /*$$=$1*/; attach_args: Sconst /*$$=$1*/; /* XXX should be converted by fmgr? */ AexprConst: Iconst { $$ = make_const ( $1 ) ; Input_is_integer = true; } | FCONST { $$ = make_const ( $1 ) ; } | CCONST { $$ = make_const ( $1 ) ; } | Sconst { $$ = make_const ( $1 ) ; Input_is_string = true; } | ParamNo { $$ = lispCons(lispInteger(get_paramtype((Param)$1)), $1, -1); } | Pnull { $$ = LispNil; Typecast_ok = false; } ; ParamNo: PARAM { ObjectId toid; int paramno; paramno = CInteger($1); toid = param_type(paramno); if (!ObjectIdIsValid(toid)) { elog(WARN, "Parameter '$%d' is out of range", paramno); } $$ = (LispValue) MakeParam(PARAM_NUM, (AttributeNumber) paramno, (Name)"", (ObjectId)toid, (List) NULL); } ; NumConst: Iconst /*$$ = $1 */ | FCONST { $$ = yylval; } ; Iconst: ICONST { $$ = yylval; } Sconst: SCONST { $$ = yylval; } Id: IDENT { $$ = yylval; } ; SpecialRuleRelation: CURRENT { if (QueryIsRule) $$ = lispString("*CURRENT*"); else elog(WARN,"\"current\" used in non-rule query"); } | NEW { if (QueryIsRule) $$ = lispString("*NEW*"); else elog(WARN,"NEW used in non-rule query"); } ; Function: FUNCTION { $$ = yylval ; } ; Aggregate: AGGREGATE { $$ = yylval ; } ; Index: INDEX { $$ = yylval ; } ; Indexable: INDEXABLE { $$ = yylval ; } ; Key: KEY { $$ = yylval ; } ; Nonulls: NONULLS { $$ = yylval ; } ; Operator: OPERATOR { $$ = yylval ; } ; Sort: SORT { $$ = yylval ; } ; Type: P_TYPE { $$ = yylval ; } ; Using: USING { $$ = yylval ; } ; With: WITH { $$ = yylval ; } ; Pnull: PNULL { $$ = yylval ; } ; %% parser_init(typev, nargs) ObjectId *typev; int nargs; { NumLevels = 0; p_target = LispNil; p_qual = LispNil; p_root = LispNil; p_priority = lispInteger(0); p_ruleinfo = LispNil; p_rtable = LispNil; p_last_resno = 1; p_numlevels = 0; p_target_resnos = LispNil; ResdomNoIsAttrNo = false; QueryIsRule = false; Input_is_string = false; Input_is_integer = false; Typecast_ok = true; param_type_init(typev, nargs); } LispValue make_targetlist_expr ( name , expr ) LispValue name; LispValue expr; { extern bool ResdomNoIsAttrNo; extern Relation parser_current_rel; int type_id,type_len, attrtype, attrlen; int resdomno; Relation rd; if(ResdomNoIsAttrNo && (expr == LispNil) && !Typecast_ok){ /* expr is NULL, and the query is append or replace */ /* append, replace work only on one relation, so multiple occurence of same resdomno is bogus */ rd = parser_current_rel; Assert(rd != NULL); resdomno = varattno(rd,CString(name)); attrtype = att_typeid(rd,resdomno); attrlen = tlen(get_id_type(attrtype)); expr = lispCons( lispInteger(attrtype), (LispValue) MakeConst((ObjectId) attrtype, (Size) attrlen, (Datum) LispNil, (bool)1, (bool) 0 /* ignored */)); Input_is_string = false; Input_is_integer = false; Typecast_ok = true; if( lispAssoc( lispInteger(resdomno),p_target_resnos) != -1 ) { elog(WARN,"two or more occurence of same attr"); } else { p_target_resnos = lispCons( lispInteger(resdomno), p_target_resnos); } return ( lispCons ((LispValue)MakeResdom ((AttributeNumber)resdomno, (ObjectId) attrtype, ISCOMPLEX(attrtype), (Size)attrlen , (Name)CString(name), (Index) 0 , (OperatorTupleForm) 0 , 0 ) , lispCons((LispValue)CDR(expr),LispNil)) ); } type_id = CInteger(CAR(expr)); type_len = tlen(get_id_type(type_id)); if (ResdomNoIsAttrNo) { /* append or replace query */ /* append, replace work only on one relation, so multiple occurence of same resdomno is bogus */ rd = parser_current_rel; Assert(rd != NULL); resdomno = varattno(rd,CString(name)); attrtype = att_typeid(rd,resdomno); attrlen = tlen(get_id_type(attrtype)); if(Input_is_string && Typecast_ok){ Datum val; if (CInteger(CAR(expr)) == typeid(type("unknown"))){ val = textout((struct varlena *)get_constvalue((Const)CDR(expr))); }else{ val = get_constvalue((Const)CDR(expr)); } CDR(expr) = (LispValue) MakeConst(attrtype, attrlen, (Datum)fmgr(typeid_get_retinfunc(attrtype),val,get_typelem(attrtype)), false, true /*??? Maybe correct-- 80% chance */); } else if((Typecast_ok) && (attrtype != type_id)){ CDR(expr) = (LispValue) parser_typecast2 ( expr, get_id_type((long)attrtype)); } else if (attrtype != type_id) elog(WARN, "unequal type in tlist : %s \n", CString(name)); Input_is_string = false; Input_is_integer = false; Typecast_ok = true; if( lispAssoc( lispInteger(resdomno),p_target_resnos) != -1 ) { elog(WARN,"two or more occurence of same attr"); } else { p_target_resnos = lispCons( lispInteger(resdomno), p_target_resnos); } } else { resdomno = p_last_resno++; attrtype = type_id; attrlen = type_len; } return ( lispCons ((LispValue)MakeResdom ((AttributeNumber)resdomno, (ObjectId) attrtype, ISCOMPLEX(attrtype), (Size) attrlen , (Name) CString(name), (Index)0 , (OperatorTupleForm)0 , 0 ) , lispCons(CDR(expr),LispNil)) ); } @ 4.15 log @fix Array node construction -> arrayhigh was being set bogusly @ text @d5 1 a5 1 $Header: /private/mer/pg/src/parser/RCS/gram.y,v 4.14 1992/08/13 22:15:31 mer Exp mer $ d921 2 d954 2 @ 4.14 log @fix core dump - trying to cast a non constant node .l @ text @d5 1 a5 1 $Header: /private/mer/pg/src/parser/RCS/gram.y,v 4.13 1992/08/03 18:15:19 mer Exp $ d1588 1 a1588 1 $2, 0); @ 4.13 log @pull string from lisp node before warning about a missing reln @ text @d5 1 a5 1 $Header: /private/mer/pg/src/parser/RCS/gram.y,v 4.12 1992/07/29 20:25:53 mao Exp mer $ d1649 1 @ 4.12 log @minor cleanup @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 4.11 1992/07/29 17:53:22 mer Exp mao $ d931 1 a931 1 elog(WARN,"notify: relation %s doesn't exist",$2); @ 4.11 log @fix listen command - relation_name is now a LispValue @ text @d5 1 a5 1 $Header: /private/mer/pg/src/parser/RCS/gram.y,v 4.10 1992/07/29 17:05:58 mer Exp mer $ d1921 1 a1921 2 if ($3 != LispNil) /* If a_expr is NULL, CAR($3) gives a core dump*/ if (ISCOMPLEX(CInteger(CAR($3)))) @ 4.10 log @back out my change it was wrong @ text @d5 1 a5 1 $Header: /private/mer/pg/src/parser/RCS/gram.y,v 4.9 1992/07/29 04:34:00 mer Exp mer $ d952 1 a952 1 parser_current_rel = heap_openr($2); @ 4.9 log @tried to create a left operator when we were dealing with a right operator and vice versa @ text @d5 1 a5 1 $Header: /private/mer/pg/src/parser/RCS/gram.y,v 4.8 1992/07/28 22:47:17 sunita Exp mer $ d1652 1 a1652 1 { $$ = make_op(lispString("-"), LispNil, $2, 'r'); d1696 1 a1696 1 { $$ = make_op ( $1, LispNil, $2, 'r'); d1699 1 a1699 1 { $$ = make_op ( $2, $1, LispNil, 'l'); @ 4.8 log @modification to allow replacing an attribute by NULL to work. @ text @d5 1 a5 1 $Header: /home2/sunita/postgres/src/parser/RCS/gram.y,v 4.7 1992/07/26 23:49:29 mao Exp sunita $ d1652 1 a1652 1 { $$ = make_op(lispString("-"), LispNil, $2, 'l'); d1696 1 a1696 1 { $$ = make_op ( $1, LispNil, $2, 'l'); d1699 1 a1699 1 { $$ = make_op ( $2, $1, LispNil, 'r'); @ 4.7 log @fix operator precedence rules @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 4.6 1992/07/24 22:00:26 mao Exp mao $ d1921 1 @ 4.6 log @HAH! no shift/reduce errors! @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 4.5 1992/07/24 21:19:09 mao Exp mao $ a115 2 %nonassoc Op %right '=' d119 2 d127 1 a128 1 %nonassoc '<' '>' @ 4.5 log @unify handling of bool, non-bool expressions and get rid of an s/r error. @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 4.4 1992/07/17 23:28:04 mao Exp mao $ a580 1 elog(WARN, "merge is unsupported in version 3"); d582 1 d1388 5 a1392 5 star: '*' ; a1394 1 | star d1521 1 a1521 1 | relation_name '*' a1650 1 | spec { Typecast_ok = false; } a1691 1 /* XXX Or other stuff.. */ d1776 1 a1776 1 elog(WARN, "array index expressions must yield type int4"); d1782 1 a1782 2 expr_list: | a_expr { ELEMENT ; } a1973 1 adt_name: Id /*$$=$1*/; a1990 10 spec: adt_name '[' '$' spec_tail ']' { $$ = (LispValue)MakeParam( (int)$4,(AttributeNumber)0,(Name)0,(ObjectId)0, (List) NULL ) ; } ; spec_tail: Iconst /*$$ = $1*/ | '.' Id { $$ = $2 ; } ; @ 4.4 log @qual result type must be bool -- grammar is now firm on this point @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 4.3 1992/07/13 01:28:02 joey Exp mao $ d1458 8 a1465 2 | WHERE boolexpr { $$ = $2; p_qual = $$; } d1467 1 a1564 27 /********************************************************************** Boolean Expressions - qualification clause XXX - for each left, right side of boolean op, need to check that qualification is indeed boolean **********************************************************************/ boolexpr: a_expr { if (CInteger(CAR($1)) != BOOLOID) elog(WARN, "where clause must return type bool, not %s", tname(get_id_type(CInteger(CAR($1))))); $$ = CDR($1); } | boolexpr AND boolexpr { $$ = MakeList ( lispInteger(AND) , $1 , $3 , -1 ); } | boolexpr OR boolexpr { $$ = MakeList ( lispInteger(OR) , $1, $3, -1 ); } | NOT boolexpr { $$ = MakeList ( lispInteger(NOT) , $2, -1 ); } | '(' boolexpr ')' { $$ = $2; } ; d1626 8 a1633 1 | WHERE boolexpr { $$ = $2; } d1730 27 a1756 1 Typecast_ok = false; } d1758 10 d1769 4 @ 4.3 log @fix grammar to call parser_init with the right arguments. To do this I has to make the pfunc_num_args and param_type_info variables be global, and not static. @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 4.2 1992/07/12 16:45:44 mao Exp joey $ d1569 7 a1575 1 { $$ = CDR($1); } @ 4.2 log @relations can no longer have complex types as atomic atts; use functions to get nested relations if you want them. @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 4.1 1992/07/11 06:13:12 mao Exp mao $ d138 1 a138 1 { parser_init(); } d144 1 a144 1 parser_init(); @ 4.1 log @fix bug in typechecking on aggregate return values (also checked this rev in with a new major number -- v4 is just about out the door) @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.101 1992/07/10 21:25:55 mao Exp $ d45 1 a45 1 /* yypvt [-1] = $1 */ d1613 1 a1613 1 Id '=' Typename d1615 10 @ 2.101 log @don't allow users to refer to complex types as atomic values in the target list. @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.100 1992/07/08 23:41:04 sunita Exp $ d1863 1 a1863 1 if (ISCOMPLEX(CInteger(type_id))) @ 2.100 log @Changes made to handle unary operators. @ text @d5 1 a5 1 $Header: /home2/sunita/postgres/src/parser/RCS/gram.y,v 2.99 1992/07/08 20:46:37 joey Exp sunita $ d1774 6 d1857 4 a1860 3 int type_id; int resdomno, type_len; List temp = LispNil; d1862 6 d1882 2 d1898 3 @ 2.99 log @set up resdom->rescomplex correctly @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.98 1992/07/08 06:31:58 mao Exp joey $ d126 1 d1674 9 d1694 6 @ 2.98 log @pass right number of args to MakeParam @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.97 1992/07/08 06:06:33 mao Exp mao $ d1760 2 a1761 1 (ObjectId)type_id, (Size)type_len, d1843 1 d1869 2 a1870 1 (ObjectId)type_id, (Size)type_len, d2062 1 d2115 1 @ 2.97 log @array ref nodes now correctly include refindexpr when they're not in the target list @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.96 1992/07/06 22:21:04 mao Exp $ d1918 1 a1918 1 { $$ = (LispValue)MakeParam( (int)$4,(AttributeNumber)0,(Name)0,(ObjectId)0 ) ; } @ 2.96 log @permit arbitrary int4 expressions in array dereferences @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.95 1992/07/06 05:02:36 mao Exp mao $ d1645 1 a1645 1 $$ = make_array_ref(temp, LISPVALUE_INTEGER($2)); @ 2.95 log @support for 'returntype = setof typename' in function definition @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.94 1992/07/04 04:03:30 mao Exp mao $ d1602 1 a1602 2 LISPVALUE_INTEGER($2), 0); d1718 5 a1722 1 '[' Iconst ']' { $$ = $2;} d1862 1 a1862 1 temp = make_array_ref(temp, LISPVALUE_INTEGER($2)); @ 2.94 log @fixes for arrays, array refs, and nested dots @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.93 1992/07/02 18:22:10 mao Exp $ a7 1 the result returned by parser is the undecorated parsetree. d9 2 a10 2 Conventions used in coding this YACC file (apart from C code): a13 14 the format of a YACC statement is : : | ... | ; except when the action is < 30 chars long in which case it is a83 1 bool is_postquel_function = false; d96 1 a96 1 IN INDEX INDEXABLE INHERITS INPUTPROC IS KEY LEFTOUTER LIGHT STORE d98 1 a98 1 PORTAL PRIORITY QUEL RIGHTOUTER RULE SCONST SORT TO TRANSACTION d451 1 d595 1 a595 1 arg is ( { , }) d602 1 a602 16 DEFINE FUNCTION def_rest AS { List args; char *pfa = "not_a_relation"; /* so current and new can be used in definition of postquel functions */ QueryIsRule = true; is_postquel_function = false; if(is_postquel_func($3)) { is_postquel_function = true; args = func_arg_list($3); } } SCONST d604 1 a604 2 QueryIsRule = false; $$ = lispCons($6, LispNil); a2113 56 #ifdef foo static int is_postquel_func(parameters) List parameters; { List assoc_list; List rest; assoc_list = CDR(parameters); foreach (rest, assoc_list) { List item = CAR(CAR(rest)); List value; /* * if this parameter does not have an associated value. */ if ( !CDR(CAR(rest)) ) continue; else value = CAR(CDR(CAR(rest))); if (!stringp(item)) continue; if (!strcmp(CString(item), "language")) { char *name; char *c; name = CString(value); for (c = name; *c != '\0'; c++) *c = (islower(*c) ? toupper(*c) : *c); if (!strcmp(name, "POSTQUEL")) return true; else return false; } } return false; } static char *postquel_func_arg(parameters) List parameters; { List assoc_list; List rest; assoc_list = CDR(parameters); foreach (rest, assoc_list) { List item = CAR(CAR(rest)); List value = CAR(CDR(CAR(rest))); if (atom(item) && (CAtom(item) == ARG)) { if (stringp(value)) { char *name = CString(value); return name; } } } elog(WARN, "no zero argument postquel functions"); } #endif foo @ 2.93 log @simplify production for defining functions, move def of NumLevels into parse_query.h (it's now needed by ylib.c in ParseFunc()). @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.92 1992/07/01 16:44:19 mao Exp mao $ d57 1 d301 1 a301 11 /************************************************************ Create a relation: QUERY : create version from TREE : ( CREATENEW ) QUERY : create ( ************************************************************/ d322 2 a323 1 while (temp != LispNil && CDR(temp) != LispNil) d325 1 a326 1 /* $$ = nappend1 ( $$, $4 ); */ d336 1 a336 4 | relation_name '[' date ']' { $$ = MakeList( $1, $3, -1); } d1615 7 a1621 8 /* * (tuple) variable definition(s) * normal tuple vars are defined as '(name type) * array tuple vars are defined as '(name type size) * if size = VARLENGTH = -1, then the array is of variable length * otherwise, the size is an integer from 1 to MAXINT */ d1626 3 a1628 5 #ifdef REAL_ARRAYS $$ = lispCons (lispInteger(-1),LispNil); #else $$ = (LispValue)"[]"; #endif d1632 3 a1634 9 /* someday, multidimensional arrays will work */ #ifdef REAL_ARRAYS $$ = lispCons ($2, LispNil); #else char *bogus = (char *) palloc(20); int retval; retval = (int) sprintf (bogus, "[%d]", CInteger($2)); $$ = (LispValue)bogus; #endif d1636 1 a1636 2 | /* EMPTY */ { NULLTREE } d1640 1 a1640 14 name opt_array_bounds { #ifdef REAL_ARRAYS $$ = lispCons($1,$2); #else char *bogus = (char *) palloc(40); int retval; if ($2 != (LispValue)NULL) { retval = (int) sprintf(bogus,"%s%s", CString($1), $2); $$ = lispString(bogus); } else $$ = $1; #endif } d1669 1 a1669 1 attr d1671 7 a1677 3 List temp = NULL; temp = HandleNestedDots($1); $$ = (LispValue)temp; a1679 6 | attr optional_indirection { $$ = (List)make_array_ref_var ( CString(CAR($1)), CString(CADR($1)), $2); } d1748 5 a1752 5 optional_indirection: '[' Iconst ']' { $$ = lispCons($2, LispNil);} | optional_indirection '[' Iconst ']' { $$ = nappend1($1, $3);} d1755 1 a1755 1 | a_expr { ELEMENT ; } d1881 1 a1881 1 | attr d1889 3 d1900 1 a1900 9 /* Obsolete, I think. -- JMH ??? if ( IsA(varnode,Var)) { set_vardotfields ( (Var)varnode , CDR(CDR($1))); } else if ( CDR(CDR($1)) != LispNil ) elog(WARN,"cannot mix procedures with unions"); */ $$=lispCons((LispValue)resnode, lispCons(varnode,LispNil)); a1901 27 | attr optional_indirection { LispValue varnode, temp; Resdom resnode; int type_id, type_len; temp = (LispValue) make_array_ref_var ( CString(CAR($1)), CString(CADR($1)), $2); type_id = CInteger(CAR(temp)); type_len = tlen(get_id_type(type_id)); resnode = MakeResdom ( p_last_resno++ , type_id, type_len, (Name)CString(CAR(last ($1) )) , 0 , 0 , 0 ); varnode = CDR(temp); /* Obsolete, I think. -- JMH ??? if ( IsA(varnode,Var)) { set_vardotfields ( (Var)varnode , CDR(CDR($1))); } else if ( CDR(CDR($1)) != LispNil ) elog(WARN,"cannot mix procedures with unions"); */ $$=lispCons((LispValue)resnode,lispCons(varnode,LispNil)); } @ 2.92 log @param nodes have target lists; initialize them. @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.91 1992/07/01 07:54:26 mao Exp $ d78 3 a80 1 static int NumLevels = 0; a610 13 Executable: OptimizableStmt { $$ = $1; if (!is_postquel_function) elog(WARN, "non-postquel functions don't use queries, you lose!"); } | SCONST { $$ = $1; }; d643 1 a643 1 Executable @ 2.91 log @generated wrong parse tree for single params w/o projections @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.90 1992/07/01 02:35:33 joey Exp mao $ d2059 2 a2060 1 (Name)"", (ObjectId)toid); @ 2.90 log @Got rid of HandleParam. Everything is handle inside of HandleNestedDots and ParseFunc @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.89 1992/06/30 22:17:27 joey Exp joey $ a57 3 bool CurrentWasUsed = false; bool NewWasUsed = false; a1718 23 if (CurrentWasUsed) { $$ = (LispValue)MakeParam ( PARAM_OLD , get_varattno((Var)temp), (Name)CString(CDR($1)), get_vartype((Var)temp)); CurrentWasUsed = false; } if (NewWasUsed) { $$ = (LispValue)MakeParam ( PARAM_NEW , get_varattno((Var)temp), (Name)CString(CDR($1)), get_vartype((Var)temp)); NewWasUsed = false; } /* Obsolete, I think. -- JMH ??? if (IsA(temp,Var)) { set_vardotfields ( (Var) temp , CDR(CDR($1))); if (null(CDR(CDR($1)))) $$ = lispCons ( lispInteger (get_vartype((Var)temp)),$$ ); } */ a1838 1 a1840 9 /* Obsolete, I think. -- JMH ??? if (IsA(varnode,Var)) { set_vardotfields((Var)varnode, CDR(CDR($1))); } else { if ( CDR(CDR($1)) != LispNil ) elog(WARN,"cannot mix procedures with unions"); } */ d2041 1 a2041 1 $$ = MakeList(lispInteger(get_paramtype((Param)$1)), d2078 1 a2078 1 if (QueryIsRule) { d2080 2 a2081 3 /* CurrentWasUsed = true; */ } else yyerror("\"current\" used in non-rule query"); d2085 1 a2085 1 if (QueryIsRule) { d2087 1 a2087 2 /* NewWasUsed = true; */ } else @ 2.89 log @should correctly deal with Params now, and also build up nested dot lists right. @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.88 1992/06/30 06:59:33 joey Exp joey $ d1720 1 a1720 4 if (IsA(CAR($1),Param)) temp = HandleParam((Param)CAR($1), (Name)CString(CADR($1))); else temp = HandleNestedDots($1); d1737 1 d1739 1 a1739 2 /* Obsolete, I think. -- JMH ??? set_vardotfields ( (Var) temp , CDR(CDR($1))); */ d1744 1 d1856 1 a1856 4 if (IsA(CAR($1),Param)) temp = HandleParam((Param)CAR($1), (Name)CString(CADR($1))); else temp = HandleNestedDots($1); d1877 1 a1877 1 $$ = lispCons((LispValue)resnode,lispCons(varnode,LispNil)); d1970 1 a1970 4 if (IsA(CAR($1),Param)) temp = HandleParam((Param)CAR($1), (Name)CString(CADR($1))); else temp = HandleNestedDots($1); a1979 1 d1988 1 a1988 1 $$=lispCons((LispValue)resnode,lispCons(varnode,LispNil)); @ 2.88 log @unify handling of nested dots and single dot @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.87 1992/06/30 01:28:56 joey Exp joey $ a1719 1 d1721 1 a1721 7 { Param f = (Param)CAR($1); set_param_tlist(f, setup_tlist(CString(CDR($1)), get_paramtype(f))); temp = (List) f; } d1837 1 a1837 1 $$ = MakeList($1, $3, -1); d1843 1 a1843 1 $$ = MakeList($1, $3, -1); d1848 2 a1849 2 attr_name { $$ = $1; } | attrs '.' attr_name { $$ = MakeList ($1, $3, -1); } d1858 4 a1861 1 temp = HandleNestedDots($1); d1873 1 d1880 1 a1880 1 d1975 4 a1978 1 temp = HandleNestedDots($1); d1989 1 d1996 1 a1996 1 d2015 1 d2022 1 @ 2.87 log @removed an apparently obsolete set_vardotfields @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.85 1992/06/29 19:23:58 joey Exp joey $ a59 1 bool attr_is_nested_dots = false; d1719 3 a1721 1 if (attr_is_nested_dots) d1723 5 a1727 1 $$ = HandleNestedDots($1); d1730 2 a1731 23 { List temp = NULL; if (IsA(CAR($1),Param)) { Param f = (Param)CAR($1); set_param_tlist(f, setup_tlist(CString(CDR($1)), get_paramtype(f))); temp = (List) f; } else temp = CDR(make_var((Name)CString(CAR($1)), (Name)CString(CADR($1)))); $$ = (LispValue)temp; if (CurrentWasUsed) { $$ = (LispValue)MakeParam ( PARAM_OLD , get_varattno((Var)temp), (Name)CString(CDR($1)), get_vartype((Var)temp)); CurrentWasUsed = false; } d1733 21 a1753 14 if (NewWasUsed) { $$ = (LispValue)MakeParam ( PARAM_NEW , get_varattno((Var)temp), (Name)CString(CDR($1)), get_vartype((Var)temp)); NewWasUsed = false; } if (IsA(temp,Var)) { /* Obsolete, I think. -- JMH ??? set_vardotfields ( (Var) temp , CDR(CDR($1))); */ if (null(CDR(CDR($1)))) $$ = lispCons ( lispInteger (get_vartype((Var)temp)),$$ ); } } d1841 1 a1841 1 relation_name '.' nested_func '.' nested_dots a1842 1 attr_is_nested_dots = true; a1844 1 $$ = nappend1($$, $5); d1846 4 a1849 12 | relation_name '.' attr_name { attr_is_nested_dots = false; INC_NUM_LEVELS(1); if( RangeTablePosn ( CString ($1),LispNil ) == 0 ) ADD_TO_RT( MakeRangeTableEntry ((Name)CString($1) , LispNil, (Name)CString($1))); $$ = MakeList ( $1, $3, -1 ); } | ParamNo '.' nested_func '.' nested_dots { attr_is_nested_dots = true; a1850 6 $$ = nappend1($$, $5); } | ParamNo '.' attr_name { attr_is_nested_dots = false; INC_NUM_LEVELS(1); $$ = MakeList ( $1, $3, -1 ); d1854 3 a1856 7 nested_func: attr_name { $$ = $1; } nested_dots: attr_name { $$ = $1; } | attr_name '.' nested_dots { $$ = MakeList($1, $3, -1); } ; d1865 1 a1865 6 if (attr_is_nested_dots) temp = HandleNestedDots($1); else temp = make_var ( (Name)CString(CAR($1)) , (Name)CString(CADR($1)), CDR(CDR($1))); d1877 7 a1883 8 if (!attr_is_nested_dots) { if (IsA(varnode,Var)) { set_vardotfields((Var)varnode, CDR(CDR($1))); } else { if ( CDR(CDR($1)) != LispNil ) elog(WARN,"cannot mix procedures with unions"); } } d1978 1 a1978 6 if (attr_is_nested_dots) temp = HandleNestedDots($1); else temp = make_var ( (Name)CString(CAR($1)) , (Name)CString(CADR($1)), CDR(CDR($1))); d1989 6 a1994 9 if (!attr_is_nested_dots) { if ( IsA(varnode,Var)) { set_vardotfields ( (Var)varnode , CDR(CDR($1))); } else if ( CDR(CDR($1)) != LispNil ) elog(WARN,"cannot mix procedures with unions"); } @ 2.86 log @initialize param_tlist @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.85 1992/06/29 19:23:58 joey Exp $ d1727 1 d1756 3 a1758 3 set_vardotfields ( (Var) temp , CDR(CDR($1))); if (null(CDR(CDR($1)))) d1821 1 a1821 1 $$ = ParseFunc ( CString ( $1 ), $3 ); @ 2.85 log @add INC_NUM_LEVELS(1) to the nested dots attr @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.84 1992/06/28 18:55:21 mao Exp joey $ a1726 1 d1728 7 a1734 1 temp = (List)fix_param($1); @ 2.84 log @clean up nested dot handling, fix up target list generation for mer @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.83 1992/06/28 05:43:19 mao Exp mao $ d1847 1 @ 2.83 log @can now declare postquel fns with simple param refs and have typechecking work correctly @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.82 1992/06/27 18:48:47 mao Exp mao $ d1883 27 a1909 24 if (attr_is_nested_dots) { $$ = HandleNestedDots($1); } else { LispValue varnode, temp; Resdom resnode; int type_id, type_len; temp = make_var ( (Name)CString(CAR($1)) , (Name)CString(CADR($1)), CDR(CDR($1))); type_id = CInteger(CAR(temp)); type_len = tlen(get_id_type(type_id)); resnode = MakeResdom ( (AttributeNumber)1, (ObjectId)type_id, (Size)type_len, (Name)CString(CAR(last ($1) )), (Index)0 , (OperatorTupleForm)0 , 0 ); varnode = CDR(temp); if ( IsA(varnode,Var)) { set_vardotfields ( (Var)varnode , CDR(CDR($1))); d1911 1 a1911 2 else if ( CDR(CDR($1)) != LispNil ) elog(WARN,"cannot mix procedures with unions"); d1913 1 a1913 2 $$ = lispCons((LispValue)resnode,lispCons(varnode,LispNil)); } d2002 4 d2007 1 a2007 3 { $$ = HandleNestedDots($1); } a2008 5 { LispValue varnode, temp; Resdom resnode; int type_id, type_len; d2012 11 a2022 8 type_id = CInteger(CAR(temp)); type_len = tlen(get_id_type(type_id)); resnode = MakeResdom ( (AttributeNumber)p_last_resno++ , (ObjectId)type_id, (Size)type_len, (Name)CString(CAR(last ($1) )) , (Index)0 , (OperatorTupleForm)0, 0 ); varnode = CDR(temp); a2029 1 $$=lispCons((LispValue)resnode,lispCons(varnode,LispNil)); d2031 3 a2033 1 } @ 2.82 log @parser support for parameters and nested dots @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.81 1992/06/26 02:55:38 joey Exp mao $ a654 1 param_type_init(args); d1727 6 a1732 3 temp = CDR ( make_var ((Name)CString(CAR ($1)) , (Name)CString(CADR($1)), CDR(CDR($1)))); d1745 1 a1745 2 get_varattno((Var)temp), (Name)CString(CDR($1)), a1755 11 else if(IsA(CAR(temp),Func)) { printf("foo"); $$ = lispCons(lispInteger(get_functype((Func) CAR(temp))), $$); } else if (IsA(temp,LispList) ) { $$ = lispCons ( lispInteger (get_vartype((Var)CADR((List)temp))), $$ ); } d2185 3 a2187 1 parser_init() d2204 2 @ 2.81 log @fix up some handling of nested dots @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.80 1992/06/25 22:14:57 sunita Exp joey $ a99 1 static bool Params_ok = false; d149 1 a149 1 %token PARAM AS BASE COMPLEX a479 2 | BASE | COMPLEX a629 1 finput = BASE|COMPLEX, foutput = BASE|COMPLEX, a652 1 Params_ok = true; a653 11 #ifdef foo pfa = postquel_func_arg($3); NewOrCurrentIsReally = lispString((char *)$4); ADD_TO_RT ( MakeRangeTableEntry ( (Name)pfa, LispNil, (Name)"*CURRENT*" ) ); ADD_TO_RT ( MakeRangeTableEntry ( (Name)pfa, LispNil, (Name)"*NEW*" )); #endif foo d1870 10 d1883 2 a1884 4 name { $$ = $1; } d1886 2 a1887 9 attr_name { $$ = $1; } | name '.' nested_dots { /* check that first nested dot is valid */ $$ = MakeList($1, $3, -1); } d1952 1 a1952 1 { p_target = nappend1(p_target,$3); $$ = p_target;} d2126 3 a2128 28 | PARAM { if (Params_ok) { ObjectId toid; int aid; char temp[8]; if (lispIntegerp($1)) { aid = CInteger($1); toid = param_type(aid); if (!ObjectIdIsValid(toid)) { elog(WARN, "Parameter '$%d' is out of range", aid); } $$ = (List) lispCons(lispInteger(toid), (LispValue) MakeParam(PARAM_NUM, (AttributeNumber)aid, (Name)"foop", (ObjectId)toid)); } else { toid = param_type_complex(CString($1)); if (!ObjectIdIsValid(toid)) { elog(WARN, "'$%s' is not an attribute of current relation", CString($1)); } $$ = (List) lispCons(lispInteger(toid), (LispValue) MakeParam(PARAM_NAMED, 0, CString($1), toid)); } a2129 5 else { Params_ok = false; elog(WARN, "Can't use parameters here"); } } d2134 15 a2211 1 Params_ok = false; @ 2.80 log @grammer changed to allow "ISNULL" and "NOTNULL" queries. @ text @d5 1 a5 1 $Header: /home2/sunita/postgres/src/parser/RCS/gram.y,v 2.79 1992/06/25 06:26:36 joey Exp sunita $ d616 13 a644 13 Executable: OptimizableStmt { $$ = $1; if (!is_postquel_function) elog(WARN, "non-postquel functions don't use queries, you lose!"); } | SCONST { $$ = $1; }; d1873 2 a1874 2 $$ = MakeList($1, $3); $$ = nconc($$, $5); @ 2.79 log @distinguish between simple attributes and nested dots @ text @d5 1 a5 1 $Header: /private/joey/pg/src/parser/RCS/gram.y,v 2.78 1992/06/23 23:51:17 mao Exp $ d130 1 a130 1 IPORTAL d139 2 d1793 1 a1793 1 { $$ = make_op(lispString("-"),$2, LispNil); d1796 1 a1796 1 { $$ = make_op (lispString("+"), $1, $3 ) ; d1799 1 a1799 1 { $$ = make_op (lispString("-"), $1, $3 ) ; d1802 1 a1802 1 { $$ = make_op (lispString("/"), $1, $3 ) ; d1805 1 a1805 1 { $$ = make_op (lispString("*"), $1, $3 ) ; d1808 1 a1808 1 { $$ = make_op (lispString("<"), $1, $3 ) ; d1811 1 a1811 1 { $$ = make_op (lispString(">"), $1, $3 ) ; d1814 1 a1814 1 { $$ = make_op (lispString("="), $1, $3 ) ; d1826 1 a1826 1 { $$ = make_op ( $2, $1 , $3 ); d1843 14 @ 2.78 log @minor cleanup of adam's stuff; disallow refs to magic system catalogs. @ text @d5 1 a5 1 $Header: /private/mao/postgres/src/parser/RCS/gram.y,v 2.77 1992/06/23 21:51:03 mao Exp $ d60 1 d1734 2 d1737 4 d1781 1 d1828 1 d1854 9 a1862 2 relation_name '.' attr_name { d1868 13 a1880 1 $$ = MakeList ( $1 , $3 , -1 ); d1882 4 a1885 3 | attr '.' attr_name { $$ = nappend1 ( $1, $3 ); d1887 1 a1887 1 ; d1890 8 a1897 2 attr { d1921 1 d2009 7 a2015 1 { d2039 1 @ 2.77 log @checking in adam's changes to extend postquel function support -- not yet tested @ text @d5 1 a5 1 $Header: /home/postgres/glass/RCS/gram.y,v 2.76 1992/03/31 23:12:04 mer Exp $ d37 4 d629 1 a629 1 Executable: OptimizableStmt d2034 6 a2039 9 /* * Catch references to pg_log and disallow them. * XXX There are probably other system relations that * we should add to this list. */ if (strncmp(CString($1), LogRelationName, 16) == 0) elog(WARN, "%s cannot be accessed by users", LogRelationName); d2098 1 a2098 2 } else { @ 2.76 log @change accessor functions into macros @ text @d5 1 a5 1 $Header: /users/mer/pg/src/parser/RCS/gram.y,v 2.75 1992/03/06 22:18:06 clarsen Exp mer $ d143 1 a143 1 %token PARAM AS d474 2 d613 1 a630 2 d640 1 a640 1 DEFINE FUNCTION def_rest AS d642 1 d650 1 d652 1 d662 3 d666 1 a667 1 } d1730 4 a1733 4 Var temp = (Var)NULL; temp = (Var)CDR ( make_var ( (Name)CString(CAR ($1)) , (Name)CString(CADR($1)) )); d1751 19 a1769 13 if (IsA(temp,Var)) { set_vardotfields ( temp , CDR(CDR($1))); $$ = lispCons ( lispInteger (get_vartype((Var)temp)), $$ ); } else if (IsA(temp,LispList) ) { $$ = lispCons ( lispInteger (get_vartype((Var)CADR((List)temp))), $$ ); } else { elog(WARN, "Var or union expected, not found"); } } d1864 2 a1865 1 (Name)CString(CADR($1))); d1975 2 a1976 1 (Name)CString(CADR($1))); d2086 24 a2109 9 aid = CInteger($1); toid = param_type(aid); if (!ObjectIdIsValid(toid)) { elog(WARN, "Parameter '$%d' is out of range", aid); } $$ = (List) lispCons(lispInteger(toid), (LispValue) MakeParam(PARAM_NUM, (AttributeNumber)aid, (Name)"foop", (ObjectId)toid)); d2279 1 a2279 1 d2334 1 @ 2.75 log @Binary Portals @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.74 92/03/06 07:57:49 mer Exp Locker: clarsen $ d1861 3 a1863 1 set_vardotfields ( (Var)varnode , CDR(CDR($1))); d1971 1 d1973 1 d1996 1 d1998 1 @ 2.74 log @be sure to close parser_current_rel when we're done with it. @ text @d5 1 a5 1 $Header: /users/mer/pg/src/parser/RCS/gram.y,v 2.73 1992/03/05 22:52:46 clarsen Exp mer $ d124 2 a125 1 STDIN STDOUT VACUUM PARALLEL AGGREGATE NOTIFY LISTEN d1524 14 @ 2.73 log @remove red-red @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.72 92/02/25 15:30:08 clarsen Exp Locker: clarsen $ d1181 1 d1214 2 d1310 1 @ 2.72 log @async portals. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.71 92/02/12 13:26:15 olson Exp Locker: clarsen $ a178 1 | NotifyStmt d974 1 a974 7 NotifyStmt: NOTIFY relation_name { $$ = MakeList(KW(notify),$2,-1); } ; NotifyOptStmt: NOTIFY relation_name d989 3 a991 1 elog(WARN,"invalid relation name"); d1010 6 d1131 1 a1131 1 | NotifyOptStmt @ 2.71 log @accept "where" clause in "define index" commands @ text @d5 1 a5 1 $Header: src/parser/RCS/gram.y,v 2.70 92/02/07 10:49:55 hong Exp Locker: olson $ d124 3 a126 2 STDIN STDOUT VACUUM PARALLEL AGGREGATE d178 2 d185 1 a185 1 | OptimizableStmt d839 2 a840 2 $$ = lispCons ( $8, lispCons ( p_rtable, NULL )); $$ = lispCons ( $4, $$ ); d848 3 a850 3 t = lispCons(CADR($2), LispNil); t = lispCons(KW(rule), t); $$ = lispCons(t, $$); d852 2 a853 2 $$ = lispCons ( CAR($2), $$ ); $$ = lispCons ( KW(define), $$ ); d855 1 a855 1 $$ = nappend1 ( $8, $5 ); d857 3 a859 3 $$ = lispCons ( KW(rule), $$ ); $$ = lispCons ( CAR($2), $$ ); $$ = lispCons ( KW(define), $$ ); d973 7 d981 16 d998 21 d1124 1 d1130 2 a1131 1 | DeleteStmt /* by default all are $$=$1 */ @ 2.70 log @fixed prototyping warnings @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.69 92/02/05 22:18:13 mer Exp $ d576 1 a576 1 Using access_method '(' index_params ')' with_clause d581 3 a583 7 $$ = lispCons($12,LispNil); $$ = lispCons($10,$$); $$ = lispCons($8,$$); $$ = lispCons($4,$$); $$ = lispCons($6,$$); $$ = lispCons(KW(index),$$); $$ = lispCons(KW(define),$$); @ 2.69 log @bug fix in checking for POSTQUEL functions @ text @d5 1 a5 1 $Header: /users/mer/postgres/src/parser/RCS/gram.y,v 2.68 1991/12/12 02:17:11 mer Exp mer $ d2146 2 a2147 2 fmgr(typeid_get_retinfunc(attrtype),val,get_typelem(attrtype)), 0,1 /*??? Maybe correct-- 80% chance */); @ 2.68 log @disallow pg_log in user queries. @ text @d5 1 a5 1 $Header: /users/mer/postgres/src/parser/RCS/gram.y,v 2.67 1991/12/10 17:51:30 mer Exp mer $ d2187 9 a2195 1 List value = CAR(CDR(CAR(rest))); d2205 4 a2208 1 if (!strcmp(name, "POSTQUEL")) return true; @ 2.67 log @fix arg checking error for function calls with 0 args @ text @d5 1 a5 1 $Header: /users/mer/postgres/src/parser/RCS/gram.y,v 2.66 1991/11/21 05:22:49 mer Exp mer $ d36 1 d1942 14 a1955 1 | Id /* $$ = $1 */; @ 2.66 log @fix prototype warn @ text @d5 1 a5 1 $Header: /users/mer/postgres/src/parser/RCS/gram.y,v 2.65 1991/11/20 13:11:07 mer Exp mer $ d1738 6 @ 2.65 log @can't use toupper indiscriminately @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.64 91/11/19 18:18:43 glass Exp Locker: mer $ d650 1 a650 1 NewOrCurrentIsReally = lispString($4); @ 2.64 log @postquel function fix @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.63 91/11/17 21:09:05 mer Exp Locker: glass $ d32 1 d2176 1 a2176 1 *c = toupper(*c); @ 2.63 log @prototyping @ text @d5 1 a5 1 $Header: /users/mer/postgres/src/parser/RCS/gram.y,v 2.62 1991/11/13 08:45:21 clarsen Exp mer $ a44 1 d94 1 d621 1 a621 1 Executable: OptimizableStmt d624 5 d630 1 a630 1 | SCONST d640 1 d644 15 d2158 43 @ 2.62 log @prototyping @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.61 91/11/05 07:21:04 mer Exp Locker: clarsen $ d1771 1 a1771 1 $$ = lispCons(resnode,lispCons(varnode,LispNil)); d1845 1 a1845 1 temp = lispCons (MakeResdom((AttributeNumber)resdomno, d1879 1 a1879 1 $$ = lispCons(resnode,lispCons(varnode,LispNil)); d1902 1 a1902 1 $$ = lispCons(resnode,lispCons(varnode,LispNil)); d1964 1 a1964 1 $$ = (List) lispCons(lispInteger(toid), d2064 1 a2064 1 expr = lispCons( lispInteger(attrtype), d2076 1 a2076 1 return ( lispCons (MakeResdom ((AttributeNumber)resdomno, d2082 1 a2082 1 lispCons((Var)CDR(expr),LispNil)) ); d2128 1 a2128 1 return ( lispCons (MakeResdom ((AttributeNumber)resdomno, d2133 1 a2133 1 lispCons((Var)CDR(expr),LispNil)) ); @ 2.61 log @minor fix for aggregates @ text @d5 1 a5 1 $Header: /users/mer/postgres/src/parser/RCS/gram.y,v 2.60 1991/10/25 02:19:12 joey Exp mer $ d919 1 a919 1 ADD_TO_RT ( MakeRangeTableEntry ( CString(CAR($4)), d921 2 a922 2 "*CURRENT*" ) ); ADD_TO_RT ( MakeRangeTableEntry ( CString(CAR($4)), d924 1 a924 1 "*NEW*" )); d1082 1 a1082 1 ADD_TO_RT( MakeRangeTableEntry(CString($5), d1084 1 a1084 1 CString($5))); d1134 1 a1134 1 ADD_TO_RT (MakeRangeTableEntry (CString($5), d1136 1 a1136 1 CString($5))); d1154 1 a1154 1 ADD_TO_RT(MakeRangeTableEntry (CString ($5), d1156 1 a1156 1 CString($5))); d1208 1 a1208 1 ADD_TO_RT( MakeRangeTableEntry (CString($5), d1210 1 a1210 1 CString($5))); d1636 2 a1637 2 temp = (Var)CDR ( make_var ( CString(CAR ($1)) , CString(CADR($1)) )); d1644 1 a1644 1 CString(CDR($1)), d1652 1 a1652 1 CString(CDR($1)), d1738 1 a1738 1 ADD_TO_RT( MakeRangeTableEntry (CString($1) , d1740 1 a1740 1 CString($1))); d1756 2 a1757 2 temp = make_var ( CString(CAR($1)) , CString(CADR($1))); d1760 5 a1764 4 resnode = MakeResdom ( 1, type_id, type_len, CString(CAR(last ($1) )) , 0 , 0 , 0 ); d1767 1 a1767 1 set_vardotfields ( varnode , CDR(CDR($1))); d1809 1 a1809 1 p_target = ExpandAll(CString($1), &p_last_resno); d1813 1 a1813 1 CDR(temp) = ExpandAll( CString($1), &p_last_resno); d1826 1 a1826 1 p_target = ExpandAll(CString($3), &p_last_resno); d1830 1 a1830 1 CDR(temp) = ExpandAll( CString($3), &p_last_resno); d1845 6 a1850 5 temp = lispCons (MakeResdom(resdomno, type_id, type_len, CString($1), 0, 0, 0) , lispCons(CDR($3), LispNil) ); d1864 2 a1865 1 temp = make_var ( CString(CAR($1)) , CString(CADR($1))); d1868 5 a1872 4 resnode = MakeResdom ( p_last_resno++ , type_id, type_len, CString(CAR(last ($1) )) , 0 , 0 , 0 ); d1875 1 a1875 1 set_vardotfields ( varnode , CDR(CDR($1))); d1894 1 a1894 1 CString(CAR(last ($1) )) d1898 1 a1898 1 set_vardotfields ( varnode , CDR(CDR($1))); d1938 1 a1938 1 { $$ = (LispValue)MakeParam( $4 ) ; } d1965 2 a1966 1 MakeParam(PARAM_NUM, aid, "foop", toid)); d2065 1 a2065 1 MakeConst(attrtype, attrlen, LispNil, 1)); d2076 6 a2081 4 return ( lispCons (MakeResdom (resdomno, attrtype, attrlen , CString(name), 0 , 0 , 0 ) , d2099 1 a2099 1 val = textout(get_constvalue(CDR(expr))); d2101 1 a2101 1 val = get_constvalue(CDR(expr)); d2104 2 a2105 2 fmgr(typeid_get_retinfunc(attrtype),val,get_typelem(attrtype)), 0); d2128 5 a2132 4 return ( lispCons (MakeResdom (resdomno, attrtype, attrlen , CString(name), 0 , 0 , 0 ) , @ 2.60 log @changed function definition stuff around to merge C and POSTQUEL @ text @d5 1 a5 1 $Header: /users/joey/pg/src/parser/RCS/gram.y,v 2.59 1991/09/29 00:21:06 mer Exp $ d1760 1 a1760 1 resnode = MakeResdom ( p_last_resno++ , @ 2.59 log @function index syntax @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.58 91/09/08 16:21:26 glass Exp Locker: mer $ d139 1 a139 1 %token PARAM d608 10 a617 5 define c function ... define postquel function '(' rel-name ')' returns is TREE: (define cfunction) ... XXX - document this d619 1 a619 1 postquel function: d621 9 a629 2 (define pfunction "func-name" "rel-name" "postquel-optimizable-stmt") a630 2 ************************************************************/ d633 14 a646 59 DEFINE C_FN FUNCTION def_rest { $$ = lispCons (KW(cfunction) , $4 ); $$ = lispCons (KW(define) , $$ ); } | DEFINE POSTQUEL FUNCTION name '(' relation_name ')' RETURNS relation_name IS { extern char *Ch; char *bogus = NULL; int x = strlen(Ch); QueryIsRule = true; NewOrCurrentIsReally = $6; /* * NOTE: 'CURRENT' must always have a varno * equal to 1 and 'NEW' equal to 2. */ ADD_TO_RT ( MakeRangeTableEntry ( CString($6), LispNil, "*CURRENT*" ) ); ADD_TO_RT ( MakeRangeTableEntry ( CString($6), LispNil, "*NEW*" )); p_last_resno = 4; bogus = (char *) palloc(x+1); bogus = strcpy ( bogus, Ch ); $10 = lispString(bogus); } OptimizableStmt { $$ = lispCons ( $10, LispNil ); $$ = lispCons ( $6 , $$ ); $$ = lispCons ( $4, $$ ); $$ = lispCons ( KW(pfunction), $$ ); $$ = lispCons ($1, $$ ); QueryIsRule = false; } | DEFINE P_FUNCTION name '(' def_list ')' { param_type_init($5); } RETURNS def_elem IS { Params_ok = true; } OptimizableStmt { $$ = lispCons($12, LispNil); $$ = lispCons($9, $$ ); $$ = lispCons($5, $$ ); $$ = lispCons($3, $$); $$ = lispCons(KW(postquel), $$); $$ = lispCons($1, $$); Params_ok = false; }; @ 2.58 log @initial postquel function checkin @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.57 91/08/18 01:54:06 caetta Exp Locker: glass $ d574 1 a574 1 Using access_method '(' index_list ')' with_clause d1378 4 d1386 10 @ 2.57 log @allows aggregate definition/removal @ text @d5 1 a5 1 $Header: parser/RCS/gram.y,v 2.56 91/08/15 22:27:48 glass Exp Locker: caetta $ d94 1 a94 1 d122 1 a122 1 STDIN STDOUT VACUUM PARALLEL AGGREGATE d139 1 a139 1 d661 21 a681 1 ; d1970 19 d2056 1 @ 2.56 log @updated merge deprecation notice @ text @d5 1 a5 1 $Header: parser/RCS/gram.y,v 2.55 91/08/15 17:09:33 mao Exp Locker: glass $ d122 1 a122 1 STDIN STDOUT VACUUM PARALLEL d164 1 d662 1 d664 7 d733 1 a733 1 Function | Type | Index | RuleType | VIEW; d1774 1 a1774 1 aggregate: d1778 1 d1788 2 a1789 2 * aggregate brackets. * this will be the aggregate node's outer child. d1792 1 a1792 1 $$ = ParseAgg(CString($1), query2, $3); d1796 1 a1796 1 /* (rettype, "aggregate",aggname, query, tlist, -1) */ d1837 1 a1837 1 Id '=' aggregate d1843 1 a1843 1 type_len = tlen(type_id); d1987 1 @ 2.55 log @don't let user use a portal unless we're inside a begin/end xact block @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.54 91/08/15 17:01:50 caetta Exp Locker: mao $ d594 1 a594 1 XXX - unsupported in version 1 (outside of parser) d600 1 a600 1 elog(NOTICE, "merge is unsupported in version 1"); @ 2.54 log @aggregates added: shouldn't break anything.... @ text @d5 1 a5 1 $Header: parser/RCS/gram.y,v 2.52 91/08/02 22:27:00 hong Exp Locker: caetta $ d1444 10 @ 2.53 log @fixed bug that made targetlists propagate across retrieve queries in a optstmtlist @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.52 91/08/02 22:27:00 hong Exp $ d51 1 d1605 4 d1731 6 d1738 41 d1817 15 a1831 4 Id '=' a_expr { $$ = make_targetlist_expr ($1,$3); } d1833 4 @ 2.52 log @added some syntax for testing parallel query execution. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.51 91/07/22 22:20:29 mao Exp Locker: hong $ d904 1 @ 2.51 log @jukebox storage manager installation @ text @d5 1 a5 1 $Header: /users/mao/postgres/src/parser/RCS/gram.y,v 2.50 1991/07/09 00:19:25 mao Exp mao $ d109 1 a109 1 UNION UNIQUE USING WHERE WITH FUNCTION OPERATOR P_TYPE d121 1 a121 1 STDIN STDOUT VACUUM d153 5 a157 1 stmt @ 2.50 log @change name of tokens for location of tables to 'store' and 'arch_store' ('location' conflicted with a name in the demo scripts). @ text @d5 1 a5 1 $Header: /users/mao/postgres/src/parser/RCS/gram.y,v 2.49 1991/07/03 00:42:55 mao Exp mao $ d369 1 a369 1 $$ = lispCons(KW(location), lispInteger(which)); d380 1 a380 1 $$ = lispCons(KW(location), lispInteger(which)); d1263 1 a1263 1 opt_star result opt_unique d1272 1 a1272 4 if ( $3 == LispNil ) command = KW(retrieve); else command = lispCons( lispInteger('*'),KW(retrieve)); d1274 2 a1275 2 root = MakeRoot(NumLevels,command, $4, p_rtable, p_priority, p_ruleinfo,$5,$10,$7); d1279 2 a1280 2 $$ = nappend1 ( $$ , $7 ); /* (eq p_target $8) */ $$ = nappend1 ( $$ , $9 ); /* (eq p_qual $10) */ @ 2.49 log @add support for smgr builtin type @ text @d5 1 a5 1 $Header: /users/mao/postgres/src/parser/RCS/gram.y,v 2.48 1991/05/05 19:42:00 mao Exp mao $ d104 1 a104 1 %token ALL ALWAYS AFTER AND ARCHIVE ARCH_LOC ARG ASCENDING BACKWARD BEFORE d106 1 a106 1 IN INDEX INDEXABLE INHERITS INPUTPROC IS KEY LEFTOUTER LIGHT LOCATION d364 1 a364 1 | LOCATION '=' Sconst d375 1 a375 1 | ARCH_LOC '=' Sconst @ 2.48 log @'vacuum' is now a postquel command @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.47 91/05/01 13:45:46 choi Exp Locker: choi $ d104 4 a107 4 %token ALL ALWAYS AFTER AND ARCHIVE ARG ASCENDING BACKWARD BEFORE BINARY BY DEMAND DESCENDING EMPTY FORWARD FROM HEAVY INTERSECT INTO IN INDEX INDEXABLE INHERITS INPUTPROC IS KEY LEFTOUTER LIGHT MERGE NEVER NEWVERSION NONE NONULLS NOT PNULL ON ONCE OR OUTPUTPROC d299 1 d304 3 a306 1 $9 = lispCons ( $9, LispNil); d360 22 @ 2.47 log @got rid of a rule production that never gets used. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.46 91/05/01 02:50:45 cimarron Exp Locker: choi $ d121 1 a121 1 STDIN STDOUT d181 1 d1007 12 @ 2.46 log @round II of converting simple functions to macros + code cleaning in general @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.45 91/04/24 20:57:46 mao Exp Locker: cimarron $ d121 1 a121 1 STDIN STDOUT ARRAY a1656 5 Typecast_ok = false; } | ARRAY TYPECAST Typename { extern List ParseArrayList(); $$ = ParseArrayList ( $1, $3 ); @ 2.45 log @get rid of unreduced rule from change to copy command syntax @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.44 91/04/12 15:58:09 choi Exp Locker: mao $ d35 1 a48 1 extern Relation amopenr(); d1049 1 a1049 1 parser_current_rel = amopenr(VarnoGetRelname(x)); d1103 1 a1103 1 parser_current_rel = amopenr(VarnoGetRelname(x)); d1175 1 a1175 1 parser_current_rel = amopenr(VarnoGetRelname(x)); @ 2.44 log @copy syntax changed to 'copy rel_name from "filename"' @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.43 91/04/11 16:01:25 choi Exp Locker: choi $ d230 1 a230 2 COPY [BINARY] [NONULLS] '(' [col_name = id]* ')' FROM/TO a236 1 ( "col_name" "id")* ) a1795 1 col_name: Id /*$$=$1*/; @ 2.43 log @fixed sort by bug. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.42 91/04/08 14:56:25 choi Exp Locker: choi $ d244 1 a244 1 relation_name '(' copy_list ')' copy_dirn copy_file_name copy_map d253 4 a256 4 $$ = nappend1($$,lispCons ($8,lispCons($9,LispNil))); if(! lispNullp($10)) $10 = lispCons($10,LispNil); $$ = nappend1($$, lispCons(KW(using), $10)); d260 1 a260 2 CDR(temp) = $6; /* $$ = nappend1 ($$ , $6 ); /* copy_list */ a284 29 copy_list: /*EMPTY*/ { NULLTREE } | copy_spec { ELEMENT ; } | copy_list ',' copy_spec { INC_LIST ; } ; copy_spec: col_name copy_eq copy_char { if ($3 != LispNil ) $3 = lispCons ($3,LispNil); $$ = lispCons ( $1, lispCons ($2, $3 ) ); } | Sconst /*$$=$1*/ ; copy_eq: /*EMPTY*/ { NULLTREE } | '=' Id { $$ = $2 ; } ; copy_char: /*EMPTY*/ { NULLTREE } | CCONST { char *cconst = (char *)CString($1); $$ = lispInteger(cconst[0]) ; } ; @ 2.42 log @statement block for rules is enclosed by [] instead of {} @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.41 91/03/29 05:29:31 kemnitz Exp Locker: choi $ d1324 6 @ 2.41 log @fmgr needed to take typelem as an argument @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.40 91/03/28 22:48:36 kemnitz Exp Locker: kemnitz $ d895 1 a895 1 | '{' OptStmtBlock '}' @ 2.40 log @got rid of compilation warning. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.39 91/03/28 22:23:43 kemnitz Exp Locker: kemnitz $ d1982 1 a1982 1 fmgr(typeid_get_retinfunc(attrtype), val), @ 2.39 log @Arrays now work in the targetlist. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.38 91/03/28 13:31:27 choi Exp Locker: kemnitz $ d1788 3 a1790 2 temp = make_array_ref_var ( CString(CAR($1)) , CString(CADR($1)), $2); @ 2.38 log @got rid of stupid comments @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.37 91/03/27 23:03:29 choi Exp Locker: choi $ d1768 22 @ 2.37 log @changed array grammar for a_expr @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.36 91/03/27 19:12:32 choi Exp Locker: choi $ d121 1 a121 1 STDIN STDOUT /* ron */ ARRAY d1633 1 a1633 1 | attr optional_indirection /* ron */ a1683 1 /* ron */ d1690 1 a1690 1 /* ron */ @ 2.36 log @fixed error in semantic action for array stuff @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.35 91/03/27 16:57:38 choi Exp Locker: choi $ d1633 1 a1633 1 | attr '[' Iconst ']' optional_indirection /* ron */ d1637 1 a1637 1 CInteger($3), $5); d1693 2 a1694 2 | '[' Iconst ']' { $$ = $2;} d1696 1 a1696 1 { $$ = lispCons($1, $3);} @ 2.35 log @ added support arrays @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.34 91/03/19 19:03:47 sp Exp Locker: choi $ d1637 1 a1637 1 CInteger($3), $4); @ 2.34 log @Now handle var-dot-fields even if they are at the right side of an "=" in the target list (e.g. retrieve(x = EMP.hobbies.score)) @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.33 91/03/19 13:49:27 sp Exp $ d121 1 a121 1 STDIN STDOUT d1633 1 a1633 1 | attr '[' Iconst ']' d1637 1 a1637 1 CInteger($3)); d1684 6 d1691 6 @ 2.33 log @Changed some elog(NOTICE) to elog(DEBUG) @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.32 91/03/16 17:27:31 sp Exp Locker: sp $ d1620 1 @ 2.32 log @Remove view added. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.31 91/03/09 13:53:05 kemnitz Exp $ d1450 1 a1450 1 elog ( NOTICE, "now consing the union'ed relations"); d1468 1 a1468 1 elog( NOTICE, "now reducing by parentheses"); @ 2.31 log @input/output to stdin/stdout @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.30 91/03/07 16:34:04 choi Exp Locker: kemnitz $ d725 1 a725 1 Function | Type | Index | RuleType ; @ 2.30 log @changed copy syntax to copy [binary] relname() from/to {"filename" | input | output} @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.29 91/03/04 13:41:53 mao Exp Locker: choi $ d121 1 a121 1 INPUT OUTPUT d1798 2 a1799 2 | INPUT { $$ = lispString(CppAsString(input)); } | OUTPUT { $$ = lispString(CppAsString(output)); } @ 2.29 log @take out spurious fflush() calls @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.28 91/03/03 19:23:36 mao Exp Locker: mao $ d121 1 d244 1 a244 1 relation_name '(' copy_list ')' copy_dirn file_name copy_map d1796 4 @ 2.28 log @sort-by can take any arbitrary operator now. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.27 91/02/28 20:54:19 mao Exp Locker: mao $ a1206 1 fflush(stdout); d1420 1 a1420 4 { /*printf("now processing where_clause\n");*/ fflush(stdout); $$ = $2; p_qual = $$; } @ 2.27 log @typecast calls to palloc @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.26 91/02/25 22:08:40 mao Exp Locker: mao $ d1438 1 @ 2.26 log @tuples are now instances ; @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.25 91/02/25 16:52:37 sp Exp Locker: mao $ d647 1 a647 1 bogus = palloc(x+1); d1549 1 a1549 1 char *bogus = palloc(20); d1565 1 a1565 1 char *bogus = palloc(40); @ 2.25 log @`SubstituteParamForNewOrCurrent' was moved to parse_query.c and the 'newruleTag' is now slighthly more complicated @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.24 91/02/25 12:07:05 choi Exp Locker: sp $ d860 5 d867 1 a867 1 { $$ = lispCons(KW(tuple), LispNil); } d873 1 a873 1 $$ = lispCons(KW(tuple), $$); d877 2 a878 2 $$ = lispCons(KW(tuple), LispNil); $$ = lispCons(KW(tuple), $$); d881 1 a881 1 { $$ = lispCons(KW(tuple), LispNil); } @ 2.24 log @now able to parse functions without any args, e.g., retrieve (x = foo()) @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.23 91/02/19 13:43:42 choi Exp Locker: choi $ d729 5 a733 1 $$ = $1; d813 1 a813 1 if ( CAtom($2) == P_TUPLE ) { d824 14 d840 4 a844 5 $$ = lispCons ( $4, $$ ); $$ = lispCons ( KW(rule), $$ ); $$ = lispCons ( $2, $$ ); $$ = lispCons ( KW(define), $$ ); d848 13 d862 1 a862 1 { $$ = KW(tuple); } d864 11 a874 1 { $$ = KW(rewrite); } d876 1 a876 1 { $$ = KW(tuple); } a1969 59 } /*-------------------------------------------------------------------- * * SubstituteParamForNewOrCurrent * * Change all the "Var" nodes corresponding to the NEW & CURRENT relation * to the equivalent "Param" nodes. * * NOTE: this routine used to be called from the parser, but now it is * called from the tuple-level rule system (when defining a rule), * and it takes an extra argument (the relation oid for the * NEW/CURRENT relation. * *-------------------------------------------------------------------- */ SubstituteParamForNewOrCurrent ( parsetree, relid ) List parsetree; ObjectId relid; { List i = NULL; Name getAttrName(); /* * sanity check... */ if (relid==NULL) { elog(WARN, "SubstituteParamForNewOrCurrent: wrong argument rel"); } foreach ( i , parsetree ) { List temp = CAR(i); if ( temp && IsA (temp,Var) ) { Name attrname = NULL; AttributeNumber attrno; if ( get_varno(temp) == 1) { /* replace with make_param(old) */ attrname = get_attname(relid, get_varattno(temp)); attrno = get_attnum(relid, attrname); CAR(i) = (List)MakeParam (PARAM_OLD, attrno, attrname, get_vartype(temp)); } if ( get_varno(temp) == 2) { /* replace with make_param(new) */ attrname = get_attname(relid, get_varattno(temp)); attrno = get_attnum(relid, attrname); CAR(i) = (List)MakeParam(PARAM_NEW, attrno, attrname, get_vartype(temp) ); } } if ( temp && temp->type == PGLISP_DTPR ) SubstituteParamForNewOrCurrent ( temp , relid ); } @ 2.23 log @minor changes for type coersion. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.22 91/02/19 13:04:39 choi Exp Locker: choi $ d1643 1 a1643 1 a_expr { ELEMENT ; } @ 2.22 log @got rid of some stupid comments. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.21 91/02/18 19:26:52 choi Exp Locker: choi $ d1902 1 a1902 1 } else if((Input_is_integer && Typecast_ok) && (attrtype != type_id)){ @ 2.21 log @added further support for type coersion @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.20 91/02/09 04:53:32 choi Exp Locker: choi $ a90 1 /* ron */ a1902 1 /* ron */ @ 2.20 log @added support for type coersion. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.19 91/02/04 15:16:49 kemnitz Exp Locker: choi $ d91 2 d1768 2 a1769 1 Iconst { $$ = make_const ( $1 ) ; } d1838 1 d1866 1 d1903 6 a1908 1 } else if (attrtype != type_id) d1911 1 @ 2.19 log @Added keywords for createdb and destroydb @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.18 91/02/02 18:26:27 mao Exp Locker: kemnitz $ d1889 6 d1896 2 a1897 2 fmgr(typeid_get_retinfunc(attrtype), get_constvalue(CDR(expr))), 0); @ 2.18 log @broke from clauses with my last change; had to put back one shift-reduce conflict to get the grammar working again. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.15 91/01/21 11:39:58 sp Exp $ d119 1 a119 1 POSTQUEL RELATION RETURNS INTOTEMP LOAD d177 2 d968 24 d1738 1 @ 2.17 log @got rid of 2 shift/reduce, one rule not reduced errors. working on the last shift/reduce error now. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.16 91/01/29 13:56:48 mao Exp Locker: mao $ d129 1 d595 1 a595 1 MERGE relation_union INTO relation_name a599 5 | MERGE relation_expr INTO relation_name { elog(NOTICE, "merge is unsupported in version 1"); $$ = MakeList ( $1, $2, $4, -1 ); } a997 1 opt_star d999 1 a999 1 relation_name d1020 1 a1020 1 if ( $3 == LispNil ) d1049 2 a1050 1 opt_star from_clause var_name d1078 1 a1078 1 if ( $3 == LispNil ) a1123 1 opt_star d1125 1 a1125 1 relation_name d1146 1 a1146 1 if ( $3 == LispNil ) d1161 1 a1161 1 ; d1163 2 a1183 1 opt_star d1185 1 a1185 1 result opt_unique d1194 1 a1194 1 if ( $2 == LispNil ) d1254 2 a1333 5 var_list IN relation_union { extern List MakeFromClause (); $$ = MakeFromClause ( $1, $3 ); } d1338 1 a1338 1 } a1369 13 relation_union: relation_expr '|' relation_expr { $$ = append ( $1, $3 ); } | relation_union '|' relation_expr { $$ = append ( $1, $3 ); } | '(' relation_union ')' { $$ = $2; } ; d1377 6 d1435 12 d1521 3 a1523 9 /* * Expression rules. We have two nearly-identical sets of productions * here; the only difference between them is that b_expr includes the * AND/OR/NOT productions for boolean expressions, and that the b_expr * stuff tosses out the type info stored in the CAR of the list for the * a_expr. These were split in order to get rid of a shift-reduce * conflict. If you change one, you need to make the same change to * the other. Sorry about that. */ d1599 1 a1599 1 | '(' a_expr ')' %prec UMINUS a1612 13 ; boolexpr: a_expr { $$ = CDR($1); } | boolexpr AND boolexpr { $$ = MakeList ( lispInteger(AND) , $1, $3, -1); } | boolexpr OR boolexpr { $$ = MakeList ( lispInteger(OR) , $1, $3, -1); } | NOT boolexpr { $$ = MakeList ( lispInteger(NOT) , $2, -1); } | '(' boolexpr ')' { $$ = $2; } @ 2.16 log @add tom vijlbrief's fix to boolean expression grouping with parens @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.16 91/01/29 13:54:15 mao Exp $ d124 3 d594 1 a594 1 MERGE relation_expr INTO relation_name d599 5 d1002 1 d1004 1 a1004 1 opt_star relation_name d1025 1 a1025 1 if ( $4 == LispNil ) d1054 1 a1054 2 from_clause opt_star var_name d1082 1 a1082 1 if ( $4 == LispNil ) d1128 1 d1130 1 a1130 1 opt_star relation_name d1151 1 a1151 1 if ( $4 == LispNil ) d1166 1 a1166 1 ; a1167 2 d1187 1 d1189 1 a1189 1 opt_star result opt_unique d1198 1 a1198 1 if ( $3 == LispNil ) a1257 2 d1336 5 d1345 1 a1345 1 } d1377 13 a1396 6 | relation_expr '|' relation_expr %prec '=' { /* union'ed relations */ elog ( NOTICE, "now consing the union'ed relations"); $$ = append ( $1, $3 ); } a1448 12 boolexpr: b_expr AND boolexpr { $$ = MakeList ( lispInteger(AND) , $1 , $3 , -1 ); } | b_expr OR boolexpr { $$ = MakeList ( lispInteger(OR) , $1, $3, -1 ); } | b_expr { $$ = $1;} | NOT b_expr { $$ = MakeList ( lispInteger(NOT) , $2, -1 ); } | '(' boolexpr ')' { $$ = $2; } ; d1523 9 a1531 3 /* * expression grammar, still needs some cleanup */ a1532 9 b_expr: a_expr { $$ = CDR($1) ; } /* necessary to strip the addnl type info XXX - check that it is boolean */ /* array_attribute: attr { $$ = make_var ( CString(CAR ($1)) , CString(CADR($1) )); } */ a1568 30 /* | attr '(' expr_list ')' { /* for now, ignore the expression list , ie assume none * exists *# Var temp = (Var)NULL; temp = (Var)CDR ( make_var ( CString(CAR ($1)) , CString(CADR($1)) )); $$ = (LispValue)temp; if (CurrentWasUsed) { $$ = (LispValue)MakeParam ( PARAM_OLD , get_varattno((Var)temp), CString(CDR($1)), get_vartype((Var)temp)); CurrentWasUsed = false; } if (NewWasUsed) { $$ = (LispValue)MakeParam ( PARAM_NEW , get_varattno((Var)temp), CString(CDR($1)), get_vartype((Var)temp)); NewWasUsed = false; } $$ = lispCons ( lispInteger (get_vartype((Var)temp)), $$ ); } */ d1607 1 a1607 1 | '(' a_expr ')' d1623 13 a1806 1 Rule: RULE { $$ = yylval ; } ; @ 2.15 log @Ooops! SubstituteParamForNewOrCurrent() was not setting the 'parmid' field of PARAM_NEW nodes.... @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.14 91/01/17 19:01:09 sp Exp $ d1440 2 @ 2.14 log @Initialize correctly the 'paramid' field of Param nodes. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.13 91/01/09 19:02:27 sp Exp $ d1973 1 a1973 1 (int32)0, @ 2.13 log @Now 'SubstituteParamForNewOrCurrent()' takes slightly different arguments and it is called from the rule definition code and not from the parser. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.12 90/10/27 17:05:51 kemnitz Exp $ d1957 1 d1962 1 d1964 1 a1964 1 (int32)0, d1971 1 @ 2.12 log @Made cast so that it compiles cleanly on all platforms. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.11 90/10/26 23:50:22 kemnitz Exp $ d43 1 d629 4 d806 3 d810 2 d868 4 d1924 16 a1939 1 SubstituteParamForNewOrCurrent ( parsetree ) d1941 1 d1946 7 a1956 5 Relation foo = amopenr ( CString(CAR(NewOrCurrentIsReally))); if (foo==NULL) { elog(WARN, "Could not open relation %s\n", CString(CAR(NewOrCurrentIsReally))); } d1958 1 a1958 1 if ( get_varno(temp) == 1 ) { d1960 1 a1960 1 attrname = getAttrName(foo, get_varattno(temp)); d1966 1 a1966 1 if ( get_varno(temp) == 2 ) { d1968 1 a1968 1 attrname = getAttrName(foo, get_varattno(temp)); d1976 1 a1976 1 SubstituteParamForNewOrCurrent ( temp ); d1979 1 @ 2.11 log @Changed "bogus = sprintf(bogus, ...)" to "retval = sprintf(bogus,...)" to fix compilation warnings on suns - this could also have caused other problems. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.10 90/10/26 11:45:23 choi Exp Locker: kemnitz $ d1458 2 a1459 2 int retval; retval = sprintf (bogus, "[%d]", CInteger($2)); d1474 1 a1474 1 int retval; d1476 1 a1476 1 retval = sprintf(bogus,"%s%s", CString($1), $2); @ 2.10 log @support for dates in "create version" command added. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.9 90/10/24 12:04:01 choi Exp Locker: choi $ d1458 2 a1459 1 bogus = sprintf (bogus, "[%d]", CInteger($2)); d1474 1 d1476 1 a1476 1 bogus = sprintf(bogus,"%s%s", CString($1), $2); @ 2.9 log @parser support for 'load "filename"' added @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.8 90/10/23 12:17:32 goh Exp Locker: choi $ d340 3 a342 2 | CREATE OptDeltaDirn NEWVERSION relation_name FROM relation_name { d345 7 @ 2.8 log @moved time-qual-creation to separate phase so that rules involving relative time quals will work right @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.8 90/10/22 17:18:48 goh Exp $ d118 1 a118 1 POSTQUEL RELATION RETURNS d171 1 d927 12 @ 2.7 log @added remove rewrite rule, remove rule still defaults to remove tuple rule @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.6 90/10/19 11:22:22 goh Exp $ d1368 1 a1368 1 $$ = MakeTimeRange($2,$4,1); d1372 1 a1372 1 $$ = MakeTimeRange($2,LispNil,0); @ 2.6 log @no longer need to check length since scanner now checks it @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.5 90/10/18 20:21:18 goh Exp $ d688 3 a690 1 remove rule d703 1 a703 1 Function | Rule | Type | Index ; d705 6 d781 1 a781 1 DEFINE newruleTag Rule name opt_support IS d798 1 a798 1 $$ = lispCons ( $3, $$ ); @ 2.5 log @added missing direction to version create command @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.5 90/10/18 18:56:12 goh Exp $ a68 2 #define MAX_ID_LENGTH 16 /* id cannot be more than 16 char long */ d1745 2 a1746 8 IDENT { /* check that Id does not exceed */ /* MAX_ID_LENGTH */ if (strlen(yyval->val) <= MAX_ID_LENGTH) $$ = yylval; else elog(WARN,"Id exceeds maximum id length %d", MAX_ID_LENGTH); } @ 2.4 log @ added a new field to Resdom node @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.3 90/10/01 16:15:19 choi Exp $ d341 1 a341 1 | CREATE NEWVERSION relation_name FROM relation_name d343 1 a343 1 $$ = MakeList ( KW(version), $3, $5,-1 ); d345 6 @ 2.3 log @check wheter id exceed 16 chars or not. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.2 90/09/20 11:29:01 goh Exp Locker: choi $ d1675 1 a1675 1 , 0 , 0 ); d1837 1 a1837 1 CString(name), 0 , 0 ) , d1876 1 a1876 1 CString(name), 0 , 0 ) , @ 2.2 log @minor typecasting fix to 2.1 @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.1 90/09/20 10:15:41 goh Exp $ d69 2 d1741 9 a1749 2 IDENT { $$ = yylval; } @ 2.1 log @fix for union queries. Should not affect anyone except lay-peng - jeff @ text @d5 1 a5 1 $Header: RCS/gram.y,v 2.0 90/09/18 12:54:34 goh Exp $ d1506 1 a1506 1 (get_vartype((Var)CADR(temp))), @ 2.0 log @hmm, I think large version numbers like 1.100 start to look real silly, so this is going to be v2.0 minor fixes, since procedures and unions are essentially incompatible (at least in the forseeable future) - jeff @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.100 90/09/04 14:32:53 choi Exp $ d389 1 a389 1 attribute OptUseOp d738 1 a738 1 RENAME attribute IN relation_name TO attribute d853 1 a853 1 relation_name '.' attribute d1215 1 a1215 1 attribute opt_class d1501 11 a1511 3 $$ = lispCons ( lispInteger (get_vartype((Var)temp)), $$ ); d1602 1 a1602 1 relation_name '.' attribute d1611 1 a1611 1 | attr '.' attribute d1696 1 a1696 1 attribute: Id /*$$=$1*/; @ 1.100 log @now allows NULL in rhs of assignment in target list. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.99 90/09/04 13:52:35 goh Exp Locker: choi $ d1667 5 a1671 1 set_vardotfields ( varnode , CDR(CDR($1))); @ 1.99 log @more support for union queries @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.98 90/08/17 12:28:03 choi Exp $ d1714 2 a1715 1 | Pnull { $$ = make_const( LispNil ); } d1792 28 a1821 1 @ 1.98 log @does a forced typecasting in make_targetlist_expr(). this will make sure that there are no garbage chars trailing a null. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.97 90/08/17 11:40:30 cimarron Exp Locker: choi $ d1321 2 a1322 1 $$ = $1; d1324 1 a1324 1 | relation_expr '|' relation_expr %prec Op d1328 1 a1328 1 $$ = lispCons ( $1, $3 ); d1330 1 a1330 1 | relation_expr '*' d1333 3 a1335 1 $$ = lispCons ( lispString("*"), $1 ); d1337 1 a1337 1 | relation_expr time_range %prec UMINUS d1340 2 a1341 1 $$ = lispCons ( $2, $1 ); a1350 51 old_Relation: relation_name opt_time_range '*' { List options = LispNil; /* printf("timerange flag = %d",(int)$2); */ if ($3 != LispNil ) /* inheritance query*/ options = lispCons(KW(inherits),options); if ($2 != LispNil ) /* time range query */ options = lispCons($2, options ); if( !RangeTablePosn(CString($1),options )) ADD_TO_RT (MakeRangeTableEntry (CString($1), options, CString($1) )); } | relation_name opt_time_range { List options = LispNil; /* printf("timerange flag = %d",(int)$2); */ if ($2 != LispNil ) /* time range query */ options = lispCons($2, options ); if( !RangeTablePosn(CString($1),options )) ADD_TO_RT (MakeRangeTableEntry (CString($1), options, CString($1) )); } ; opt_time_range: '[' opt_range_start ',' opt_range_end ']' { /* printf ("time range\n");fflush(stdout); */ $$ = MakeTimeRange($2,$4,1); } | '[' date ']' { /* printf("snapshot\n"); fflush(stdout); */ $$ = MakeTimeRange($2,LispNil,0); } | /* empty */ { $$ = lispInteger(0); } ; a1353 1 /* printf ("time range\n");fflush(stdout); */ a1357 1 /* printf("snapshot\n"); fflush(stdout); */ @ 1.97 log @added pathnames to #include statements @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.96 90/08/17 11:27:36 ong Exp Locker: cimarron $ d89 2 d1591 1 a1591 1 | spec d1593 2 a1594 1 { $$ = make_op(lispString("-"),$2, LispNil); } d1596 2 a1597 1 { $$ = make_op (lispString("+"), $1, $3 ) ; } d1599 2 a1600 1 { $$ = make_op (lispString("-"), $1, $3 ) ; } d1602 2 a1603 1 { $$ = make_op (lispString("/"), $1, $3 ) ; } d1605 2 a1606 1 { $$ = make_op (lispString("*"), $1, $3 ) ; } d1608 2 a1609 1 { $$ = make_op (lispString("<"), $1, $3 ) ; } d1611 2 a1612 1 { $$ = make_op (lispString(">"), $1, $3 ) ; } d1614 2 a1615 1 { $$ = make_op (lispString("="), $1, $3 ) ; } d1620 2 a1621 1 } d1626 2 a1627 1 { $$ = make_op ( $2, $1 , $3 ); } d1629 2 a1630 1 { $$ = lispCons ( KW(relation), $1 ); } d1635 1 a1635 1 } d1761 2 a1762 1 | Sconst { $$ = make_const ( $1 ) ; } d1825 2 d1851 10 a1860 3 if (attrtype != type_id) elog(WARN, "unequal type in tlist : %s \n", CString(name)); @ 1.96 log @fix for the grammar rule "create version ..." @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.95 90/08/03 16:38:40 choi Exp $ a30 1 #include "c.h" d32 2 d35 3 a37 3 #include "log.h" #include "palloc.h" #include "pg_lisp.h" d40 3 a42 3 #include "primnodes.h" #include "primnodes.a.h" #include "params.h" @ 1.95 log @now you can "define operator OP" where OP can be =, +, -, <, >, *, and /. you can also "remove operator OP" @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.94 90/08/03 13:02:48 choi Exp Locker: choi $ d336 1 a336 1 | CREATE NEWVERSION relation_name FROM relation_expr d338 1 a338 1 $$ = MakeList ( KW(version), $3, $5 ); @ 1.94 log @when rule body has multiple commands p_last_resno and p_target_resnos must be reinitialized between each command @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.93 90/08/01 17:24:07 choi Exp Locker: choi $ d418 9 a426 1 def_name: Id | Op ; d695 1 a695 1 REMOVE Operator Op '(' remove_operator ')' d701 15 @ 1.93 log @StripRangeTable() is removed @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.92 90/08/01 16:03:12 choi Exp Locker: choi $ d790 8 a797 2 | OptStmtBlock OptimizableStmt { $$ = nappend1($1, $2); } d986 1 a986 1 ResdomNoIsAttrNo = true; @ 1.92 log @sematic action error for OptStmtList corrected @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.91 90/07/31 12:33:34 choi Exp Locker: choi $ a777 1 StripRangeTable(); a933 1 StripRangeTable(); a992 1 StripRangeTable(); a1060 1 StripRangeTable(); a1108 1 StripRangeTable(); @ 1.91 log @semantic action for OptStmtBlock corrected @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.90 90/07/30 17:55:08 sp Version_2 Locker: choi $ d785 1 @ 1.90 log @When defining a rule if the action part is "nothing" we must still call StripRangeTable() @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.89 90/07/30 12:04:33 sp Exp $ d791 1 a791 1 { INC_LIST ; } @ 1.89 log @Now `SubstituteParamForNewOrCurrent' can handle system attributes (i.e. negative attribute numbers) @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.88 90/07/20 10:57:35 goh Exp Locker: goh $ d776 1 a776 1 if ( ! strcmp(CString($1),"nothing") ) d778 2 a779 1 else @ 1.88 log @changed default rule define type to "tuple since in version 2.0, rewrite rules won't be working yet @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.87 90/07/19 12:46:02 goh Exp Locker: goh $ d1835 1 d1840 1 a1840 1 char *attrname = NULL; d1842 4 a1846 4 if ( foo ) { attrname = (char *) &(foo->rd_att.data[get_varattno(temp)-1]->attname); } d1849 1 d1857 1 @ 1.87 log @new fromclause handling code @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.86 90/07/18 15:24:33 goh Exp Locker: goh $ d770 1 a770 1 { $$ = KW(rewrite); } @ 1.86 log @added the additional rangetable in tuple-rule definition for spyros @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.85 90/07/17 16:18:49 goh Exp Locker: goh $ d210 1 a210 1 CLUSTER Relation ON index_name OptUseOp d336 1 a336 1 | CREATE NEWVERSION relation_name FROM Relation d564 1 a564 1 MERGE Relation INTO relation_name d1252 1 a1252 1 var_list IN Relation a1287 6 new_Relation: relation_expr { $$ = FlattenRelationList ( $1 ); } ; d1318 1 a1318 1 Relation: a1827 36 } List MakeFromClause ( from_list, base_rel ) List from_list; LispValue base_rel; { /* Convert "p, p1 in proc" to "p in proc, p1 in proc" */ LispValue temp,temp2,temp3; LispValue frelname; temp = p_rtable; while(! lispNullp(CDR (temp))) { temp = CDR(temp); } /* * we depend on the base_rel * to be in the last element, for now */ frelname = CAR(CDR(CAR(temp))); printf("from relname = %s\n",CString(frelname)); fflush(stdout); CAR(CAR(temp)) = CAR(from_list); temp2 = CDR(from_list); while(! lispNullp(temp2)) { temp3 = lispCons(CAR(temp2),CDR(CAR(temp))); ADD_TO_RT(temp3); temp2 = CDR(temp2); } @ 1.85 log @changed the tuple-rule parsetree to use paramnodes instead of varnodes @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.84 90/07/17 10:33:09 goh Exp Locker: goh $ d753 3 a756 2 $$ = nappend1 ( $8, $5 ); d1885 2 a1886 1 attrname = &(foo->rd_att.data[get_varattno(temp)-1]->attname); d1890 1 a1890 1 CAR(i) = MakeParam (PARAM_OLD, d1897 1 a1897 1 CAR(i) = MakeParam(PARAM_NEW, @ 1.84 log @bugfixes ... Interesting note : the lines in make_array_ref_var actually worked even though they looked rather wierd. In any case, it's bean cleaned up. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.83 90/07/14 14:04:00 goh Exp Locker: goh $ d1879 7 a1885 1 if ( IsA (temp,Var) ) { d1888 5 a1892 1 } d1895 4 d1901 1 a1901 1 if ( temp->type == PGLISP_DTPR ) @ 1.83 log @more nitshitty little stuff that was left out when hand merging the two trees @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.82 90/07/14 10:38:47 goh Exp Locker: goh $ a747 4 $$ = nappend1 ( $8, $5 ); $$ = lispCons ( $4, $$ ); $$ = lispCons ( $3, $$ ); d752 1 a752 1 } else { d755 3 d1563 3 a1565 5 Var temp = (Var)NULL; temp = (Var) $$ = make_array_ref_var ( CString(CAR($1)), CString(CADR($1)), CInteger($3)); d1870 20 @ 1.82 log @patched as announced ... hobbies(emp) temporarily invalidated @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.80 90/07/13 15:24:06 goh Exp Locker: goh $ d1566 1 a1566 1 make_array_ref_var ( CString(CAR($1)), @ 1.81 log @patched back old from_clause stuff so we can ship 7 rules not reduced are OK, they are the new stuff that is temporarily unused @ text @d1531 1 a1531 1 | attr '(' expr_list ')' d1535 1 a1535 1 */ d1560 1 a1560 1 } @ 1.80 log @(temporarily) allow all valid constants to be typecast. In the future should consider typecasting the return results from the executor @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.79 90/07/13 13:19:59 goh Exp Locker: goh $ d1288 1 a1288 1 Relation: d1291 1 a1291 1 $$ = FlattenRelationList ( $1 ); d1323 4 a1326 3 /* old_Relation: relation_name time_range '*' d1330 1 a1330 1 #* printf("timerange flag = %d",(int)$2); *# d1332 1 a1332 1 if ($3 != LispNil ) #* inheritance query*# d1335 1 a1335 1 if ($2 != LispNil ) #* time range query *# d1343 1 a1343 1 | relation_name time_range d1347 1 a1347 1 #* printf("timerange flag = %d",(int)$2); *# d1349 1 a1349 1 if ($2 != LispNil ) #* time range query *# a1357 1 */ d1359 16 @ 1.79 log @bugfix : removes circular reference in define c function @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.78 90/07/12 21:27:52 goh Exp Locker: goh $ d1571 1 a1571 1 | a_expr TYPECAST Typename @ 1.78 log @oops, "Define" got trashed... might as well get rid of it while we're at it @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.77 90/07/12 21:14:22 goh Exp Locker: goh $ d411 1 a411 1 $2 = nappend1 ($2, $2 ); @ 1.77 log @fixes the two bugs on define c funcion and define type as reported by greg @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.76 90/07/12 12:11:56 goh Exp Locker: goh $ d538 1 a538 1 Define opt_archive Index index_name ON relation_name d741 1 a741 1 Define newruleTag Rule name opt_support IS d871 1 a871 1 Define VIEW name @ 1.76 log @aargh ... comment in wrong place. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.74 90/07/11 13:20:51 goh Exp Locker: goh $ d400 1 a400 1 Define def_type def_rest d403 1 a403 1 $$ = lispCons ($1 , $2 ); d591 1 a591 1 $$ = lispCons ($1 , $$ ); a1747 1 Define: DEFINE { $$ = yylval ; } ; @ 1.75 log @finally (?) fixes the array thing. @ text @d1479 2 a1480 2 /* XXX - check that it is boolean */ @ 1.74 log @hmm, v1.72 of gram.y had two instances of array ref nodes, merged the wrong one into 1.73 @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.73 90/07/10 12:52:36 goh Exp Locker: goh $ d1479 2 a1480 2 XXX - check that it is boolean */ /* d1486 1 a1486 9 | attr '[' Iconst ']' { Var temp = (Var)NULL; temp = (Var) make_array_ref_var ( CString(CAR($1)), CString(CADR($1)), CInteger($3)); } */ d1545 1 d1549 4 a1552 6 /* XXX - fix me after video demo */ temp = (Var)make_var ( CString(CAR($1)), CString(CADR($1)) ); $$ = lispCons ( lispInteger ( 23 ), MakeArrayRef( temp , $3 )); a1553 1 | AexprConst @ 1.73 log @merged all sorts of things into this. hope this works out ok. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.5 90/07/06 11:34:29 goh Exp Locker: goh $ d1484 1 a1484 1 $$ = make_var ( CString(CAR ($1)) , CString(CADR($1))); d1489 4 a1492 3 temp = (Var)make_var ( CString(CAR($1)), CString(CADR($1)) ); $$ = (LispValue)MakeArrayRef( temp , $3 ); @ 1.72 log @null-terminate the parse tree if opt_class not specified for define index, and remove a nested comment so that bison groks the grammar. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.71 90/05/21 00:20:21 kemnitz Exp $ d32 1 d47 3 d81 1 a81 2 YYSTYPE p_trange, p_rtable, d114 2 a115 1 REWRITE P_TUPLE TYPECAST d148 1 a148 1 | Attachas attach_args /* what are the args ? */ d159 1 d170 1 d180 1 a180 1 Addattr '(' var_defs ')' TO relation_name d182 2 a183 2 $6 = lispCons( $6 , $3); $$ = lispCons( $1 , $6); d196 3 a198 2 Close opt_id { $$ = lispCons ( $1 , lispCons ( $2 , LispNil )) ; } d210 1 a210 1 Cluster Relation ON index_name OptUseOp d230 1 a230 1 Copy copy_type copy_null d235 1 a235 1 $$ = lispCons($1,LispNil); d271 1 a271 1 | Binary d315 1 a315 1 Create relation_name '(' opt_var_defs ')' a317 1 LispValue temp = LispNil; d319 1 a319 4 $9 = lispCons ( $9, LispNil); $8 = lispCons ( $8, $9 ); $7 = lispCons ( $7, $8 ); $6 = lispCons ( $6, $7 ); d321 14 a334 9 $2 = lispCons ( $2, LispNil ); $$ = lispCons ( $1, $2 ); $$ = nappend1 ( $$, $6 ); temp = $$; while (temp != LispNil && CDR(temp) != LispNil) temp = CDR(temp); CDR(temp) = $4; /* $$ = nappend1 ( $$, $4 ); */ d336 1 a336 1 | Create Version relation_name FROM Relation d338 1 a338 3 $3 = lispCons( $3, LispNil); $3 = nappend1( $3, $5 ); $$ = lispCons( $2, $3 ); d353 2 a354 1 | Archive '=' archive_type {$$ = lispCons ($1 , $3); } d365 4 a368 1 | Inherits '(' relation_name_list ')' { $$ = lispCons ( $1, $3 ) ; } d374 4 a377 2 | Key '(' key_list ')' { $1 = lispCons ( $1, LispNil); $$ = nappend1 ($1, $3 ); } d400 1 a400 1 Define def_type def_name definition opt_def_args a401 3 if ( $5 != LispNil ) $4 = nappend1 ($4, $5 ); $3 = lispCons ($3 , $4 ); d407 8 a414 1 def_type: Function | Operator | Type ; d416 2 d461 2 a462 1 Destroy relation_name_list { $$ = lispCons($1,$2) ; } d476 1 a476 4 $3 = lispCons ( $3 , LispNil ); $2 = lispCons ( $2 , $3 ); $4 = lispCons ( $4 , $2 ); $$ = lispCons ( KW(fetch) , $4 ); d498 1 a498 4 $3 = lispCons ( $3 , LispNil ); $2 = lispCons ( $2 , $3 ); $4 = lispCons ( $4 , $2 ); $$ = lispCons ( KW(move) , $4 ); d514 1 a514 1 { $$ = lispCons ( KW(to) , lispCons( $2, LispNil )); } d544 7 a550 7 $12 = lispCons($12,LispNil); $10 = lispCons($10,$12); $8 = lispCons($8,$10); $4 = lispCons($4,$8); $6 = lispCons($6,$4); $3 = lispCons($3,$6); $$ = lispCons($1,$3); d567 1 a567 2 $$ = lispCons($1, lispCons($2,lispCons($4,LispNil))) ; d571 53 d637 1 a637 1 Purge relation_name purge_quals d639 3 a641 3 $$=nappend1(LispNil,$1); nappend1($$,$2); nappend1($$,$3); d649 1 a649 1 {$$=nappend1(LispNil,$1);} d651 1 a651 1 {$$=nappend1(LispNil,$1);} d653 1 a653 1 {$$=nappend1(LispNil,$1);$$=nappend1($$,$2);} d655 1 a655 1 {$$ = nappend1(LispNil,$2);$$=nappend1($$,$1);} d658 2 a659 4 before_clause: BEFORE date { $$ = lispCons($1, lispCons($2,LispNil)); } ; after_clause: AFTER date { $$ = lispCons($1, lispCons($2,LispNil)); } ; d677 1 a677 1 Remove remove_type name d679 1 a679 3 $3=lispCons($3,LispNil); $2=lispCons($2,$3); $$=lispCons($1,$2); d687 1 a687 1 Remove Operator Op '(' remove_operator ')' d689 3 a691 3 $3 = lispCons($3, $5); $2 = lispCons($2, lispCons($3, LispNil)); $$ = lispCons($1, $2); d699 1 a699 1 { $$ = lispCons($1, lispCons($3, LispNil)); } d714 2 a715 4 $2 = lispCons ($2 , lispCons ($6, LispNil )); $4 = lispCons ($4 , $2); $$ = lispCons ($1 , lispCons(lispString("ATTRIBUTE") ,$4 )); d719 2 a720 3 $2 = lispCons ($2, lispCons ($4, LispNil)); $$ = lispCons ($1, lispCons (lispString ("RELATION") ,$2 )); d748 3 d752 10 a761 5 $8 = nappend1 ( $8, $5 ); $4 = lispCons ( $4, $8 ); $3 = lispCons ( $3, $4 ); $2 = lispCons ( $2, $3 ); $$ = lispCons ( $1, $2 ); d770 1 a770 1 { $$ = KW(tuple); } d773 20 d794 2 a795 1 ON event TO event_object d797 4 d802 6 d810 3 a812 2 opt_qual DO opt_instead OptimizableStmt d814 2 a815 5 $$ = lispCons($9,LispNil); /* action */ $$ = lispCons($8,$$); /* instead */ $$ = lispCons($6,$$); /* event-qual */ $$ = lispCons($4,$$); /* event-object */ $$ = lispCons($2,$$); /* event-type */ d821 1 a821 1 { $$ = lispCons ( $1, lispCons ( $3, LispNil)) ; } a827 68 opt_qual: { LispValue temp; /* * Save the parser state so that this qualification * creates its own range table etc. * But as it is a rule query, we allow 'current' or 'new' */ SaveParserState(); QueryIsRule = true; } opt_from_clause where_clause { /* * create a parse tree correpsonding to the * query : * retrieve (x=1) * from * where */ LispValue root; LispValue targetList; LispValue targetListExpr; LispValue qual; StripRangeTable(); /* * create the dummy target list "(x=1)" */ targetListExpr = make_targetlist_expr( lispString("x"), make_const(lispInteger(1))); targetList = lispCons(targetListExpr, LispNil); /* * create the parse tree for this fake retrieve * statement */ root = MakeRoot(NumLevels, KW(retrieve), LispNil, /* result */ p_rtable, p_priority, p_ruleinfo, LispNil, /* unique */ LispNil, /* sort by */ targetList); qual = $3; $$ = lispCons(root, LispNil); $$ = nappend1($$, targetList); $$ = nappend1($$, qual); /* * Now restore the parser state */ RestoreParserState(); } | /* empty */ { NULLTREE ; } ; opt_from_clause: FROM from_list { $$ = $2; } | /* empty */ { NULLTREE ; } d876 1 a876 1 $$ = lispCons ( $1 , $2 ); d1176 2 a1177 1 | Archive d1190 1 a1190 1 /* empty */ { NULLTREE ; } d1222 1 a1222 5 | With '(' param_list ')' { $$ = lispCons( $1 , LispNil ); $$ = nappend1( $$ , $3 ); } d1232 1 a1232 1 { $$ = lispCons ( $1 , lispCons ($3 , LispNil )); } d1252 1 a1252 1 var_list IN from_rel_name d1254 3 a1256 22 /* Convert "p, p1 in proc" to "p in proc, p1 in proc" */ LispValue temp,temp2,temp3; LispValue frelname; temp = p_rtable; while(! lispNullp(CDR (temp))) { temp = CDR(temp); } frelname = CAR(CDR(CAR(temp))); /*printf("from relname = %s\n",CString(frelname)); fflush(stdout);*/ CAR(CAR(temp)) = CAR($1); temp2 = CDR($1); while(! lispNullp(temp2)) { temp3 = lispCons(CAR(temp2),CDR(CAR(temp))); ADD_TO_RT(temp3); temp2 = CDR(temp2); } } d1266 1 a1266 1 | Where boolexpr d1276 1 a1276 1 | Portal name d1278 1 a1278 2 $2=lispCons($2,LispNil); $$=lispCons(KW(portal),$2); d1288 5 a1292 3 from_rel_name: Relation | '<' Iconst '>' { $$ = $2; } d1294 28 d1323 3 a1325 2 Relation: relation_name opt_time_range '*' d1329 1 a1329 1 /* printf("timerange flag = %d",(int)$2); */ d1331 2 a1332 2 if ($3 != LispNil ) /* inheritance query*/ options = lispCons(lispAtom("inherits"),options); d1334 1 a1334 1 if ($2 != LispNil ) /* time range query */ d1342 1 a1342 1 | relation_name opt_time_range d1346 1 a1346 1 /* printf("timerange flag = %d",(int)$2); */ d1348 1 a1348 1 if ($2 != LispNil ) /* time range query */ d1357 1 d1359 1 a1359 1 opt_time_range: a1363 1 p_trange = $$ ; a1368 1 p_trange = $$ ; d1370 1 a1370 6 | /*EMPTY*/ { $$ = lispInteger(0); p_trange = $$; } ; d1394 1 a1394 2 { $$ = lispCons ( lispInteger(AND) , lispCons($1 , lispCons($3 ,LispNil ))) ; } d1396 1 a1396 2 { $$ = lispCons ( lispInteger(OR) , lispCons($1 , lispCons ( $3 , LispNil))); } d1400 1 a1400 2 { $$ = lispCons ( lispInteger(NOT) , lispCons ($2, LispNil )); } d1460 1 a1460 1 $$ = lispCons($1,lispCons($3,LispNil)); d1480 1 a1480 1 d1484 1 a1484 1 $$ = make_var ( CString(CAR ($1)) , CString(CDR($1)), 0); d1489 3 a1491 2 $$ = (LispValue) make_var ( CString(CAR($1), CString(CDR($1)), CInteger($3))); d1493 1 d1499 1 a1499 1 CString(CDR($1)) )); d1501 1 a1501 1 $$ = (LispValue) temp; a1502 1 /* d1510 1 a1510 1 */ d1522 30 d1554 1 d1556 5 a1560 5 LispValue tmp = (LispValue) make_array_ref_var(CString(CAR($1)), CString(CDR($1)), CInteger($3)); $$ = tmp; a1563 1 | AexprNewOrCurrent d1590 2 d1593 3 a1595 23 { extern Func MakeFunc(); extern OID funcname_get_rettype(); extern OID funcname_get_funcid(); char *funcname = CString($1); OID rettype = (OID)0; OID funcid = (OID)0; Func funcnode = (Func)NULL; LispValue i = LispNil; funcid = funcname_get_funcid ( funcname ); rettype = funcname_get_rettype ( funcname ); if ( funcid != (OID)0 && rettype != (OID)0 ) { funcnode = MakeFunc ( funcid , rettype , false ); } else elog (WARN,"function %s does not exist",funcname); foreach ( i , $3 ) { CAR(i) = CDR(CAR(i)); } $$ = lispCons (lispInteger(rettype) , lispCons ( funcnode , $3 )); d1611 1 a1611 1 $$ = lispCons ( $1 , $3 ); d1613 4 d1625 1 a1625 1 | relation_name '.' All d1638 1 a1638 1 | res_target_list ',' relation_name '.' All d1669 1 a1669 1 temp = make_var ( CString(CAR($1)) , CString(CDR($1)), 0); d1674 2 a1675 1 CString(CDR ( $1 )) , 0 , 0 ); d1677 1 d1688 2 a1689 1 Id /*$$=$1*/ d1705 1 a1717 34 AexprNewOrCurrent: NEW '.' attribute { /* * We have to check if this is * a rule. If not then this is a syntax error! */ if(!QueryIsRule) { yyerror("\"new\" used in non-rule query"); } /* * create the param node. */ $$ = make_param(PARAM_NEW, CString(CAR(NewOrCurrentIsReally)), CString($3)); } | CURRENT '.' attribute { /* * We have to check if this is * a rule. If not then this is a syntax error! */ if(!QueryIsRule) { yyerror("\"current\" used in non-rule query"); } /* * create the param node. */ $$ = make_param(PARAM_OLD, CString(CAR(NewOrCurrentIsReally)), CString($3)); } d1737 18 a1756 9 Addattr: ADD_ATTR { $$ = yylval ; } ; All: ALL { $$ = yylval ; } ; Archive: ARCHIVE { $$ = yylval ; } ; Attachas: ATTACH_AS { $$ = yylval ; } ; Binary: BINARY { $$ = yylval ; } ; Close: CLOSE { $$ = yylval ; } ; Cluster: CLUSTER { $$ = yylval ; } ; Copy: COPY { $$ = yylval ; } ; Create: CREATE { $$ = yylval ; } ; a1757 1 Destroy: DESTROY { $$ = yylval ; } ; a1760 1 Inherits: INHERITS { $$ = yylval ; } ; a1763 3 Portal: PORTAL { $$ = yylval ; } ; Purge: PURGE { $$ = yylval ; } ; Remove: REMOVE { $$ = yylval ; } ; a1767 2 Version: NEWVERSION { $$ = yylval ; } ; Where: WHERE { $$ = yylval ; } ; a1780 1 p_trange = lispInteger(0); d1833 9 a1841 6 /******************************************************************** SaveParserState: save the current parser state RestoreParserState: restore the previous parser state d1843 9 a1851 1 ********************************************************************/ d1853 1 a1853 13 static int previous_NumLevels; static LispValue previous_p_target; static LispValue previous_p_qual; static LispValue previous_p_root; static LispValue previous_p_priority; static LispValue previous_p_ruleinfo; static LispValue previous_p_rtable; static LispValue previous_p_trange; static int previous_p_last_resno; static int previous_p_numlevels; static LispValue previous_p_target_resnos; static bool previous_ResdomNoIsAttrNo; static bool previous_QueryIsRule; d1855 2 a1856 15 SaveParserState() { previous_NumLevels = NumLevels; previous_p_target = p_target; previous_p_qual = p_qual; previous_p_root = p_root; previous_p_priority = p_priority; previous_p_ruleinfo = p_ruleinfo; previous_p_rtable = p_rtable; previous_p_trange = p_trange; previous_p_last_resno = p_last_resno; previous_p_numlevels = p_numlevels; previous_p_target_resnos = p_target_resnos; previous_ResdomNoIsAttrNo = ResdomNoIsAttrNo; previous_QueryIsRule = QueryIsRule; d1858 9 a1866 18 parser_init; } RestoreParserState() { NumLevels = previous_NumLevels; p_target = previous_p_target; p_qual = previous_p_qual; p_root = previous_p_root; p_priority = previous_p_priority; p_ruleinfo = previous_p_ruleinfo; p_rtable = previous_p_rtable; p_trange = previous_p_trange; p_last_resno = previous_p_last_resno; p_numlevels = previous_p_numlevels; p_target_resnos = previous_p_target_resnos; ResdomNoIsAttrNo = previous_ResdomNoIsAttrNo; QueryIsRule = previous_QueryIsRule; @ 1.71 log @Demo hacks taken out of parser. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.70 90/05/20 21:25:09 kemnitz Exp Locker: kemnitz $ d1162 1 a1658 1 /* adt_const: Sconst /*$$=$1*/; @ 1.70 log @Rolled together functions, arrays, rules. Arrays are still demo-hacked. To be fixed shortly. @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.68 90/05/14 15:41:20 goh Exp Locker: goh $ d1501 1 a1501 1 $$ = (LispValue) lispCons ( lispInteger ( 23 ), CDR(tmp)); @ 1.69 log @functions now work @ text @d5 1 a5 1 $Header: RCS/gram.y,v 1.64 90/04/22 15:10:40 mao Exp Locker: goh $ a45 1 a164 1 d704 1 a704 1 { $$ = KW(rewrite); } d708 1 a708 2 ON event TO event_object opt_qual DO opt_instead d713 1 d717 2 a718 2 $$ = lispCons($7,$$); /* instead */ $$ = lispCons($5,$$); /* event-qual */ d734 58 a791 1 where_clause d794 7 d1457 1 a1457 1 $$ = make_var ( CString(CAR ($1)) , CString(CDR($1))); d1462 2 a1463 3 temp = (Var)make_var ( CString(CAR($1)), CString(CADR($1)) ); $$ = (LispValue)MakeArrayRef( temp , $3 ); d1472 2 a1473 1 $$ = temp; a1495 1 Var temp = (Var)NULL; d1497 5 a1501 5 temp = (Var)make_var ( CString(CAR($1)), CString(CDR($1)) ); $$ = lispCons ( lispInteger ( 23 ), MakeArrayRef( temp , $3 )); d1505 1 d1625 1 a1625 1 temp = make_var ( CString(CAR($1)) , CString(CDR($1))); d1642 1 a1642 2 SpecialRuleRelation | Id /*$$=$1*/ d1671 34 a1723 18 SpecialRuleRelation: CURRENT { if (QueryIsRule) { $$ = CAR ( NewOrCurrentIsReally ); CurrentWasUsed = true; } else yyerror("\"current\" used in non-rule query"); } | NEW { if (QueryIsRule) { $$ = CAR ( NewOrCurrentIsReally ); NewWasUsed = true; } else elog(WARN,"NEW used in non-rule query"); } d1817 59 @ 1.68 log @bugfix : "|" missing from relation_name @ text @d40 1 d47 3 d166 1 d736 1 a736 1 { NULLTREE } d1407 24 a1430 1 $$ = make_var ( CString(CAR ($1)) , CString(CDR($1))); d1473 7 a1479 1 /* Type funcrettype = get_id_type ( 95 ); */ d1481 13 a1493 2 $$ = lispCons ( lispInteger (23), MakeFunc ( 0 , 0 , false )); d1632 1 a1632 1 if (QueryIsRule) d1634 2 a1635 1 else d1640 1 a1640 1 if (QueryIsRule) d1642 2 a1643 1 else d1645 1 @ 1.67 log @minor bugfix left out a paren last time @ text @d116 2 a118 2 %left '.' %nonassoc '<' '>' d1536 1 a1536 1 Id /*$$=$1*/ @ 1.66 log @changed arrays a little so that we have demo ware. remember to change it back @ text @d1412 1 a1412 1 MakeArrayRef( temp , $3 ); @ 1.65 log @added bunch o stuff for arrays, current, new etc. @ text @d1407 1 d1410 3 a1412 1 $$ = (LispValue)MakeArrayRef( temp , $3 ); d1445 1 a1445 1 Type funcrettype = get_id_type ( 95 ); d1535 1 a1536 1 | SpecialRuleRelation @ 1.64 log @time range fix -- retrieve (...) from e in emp [ , ] now works. @ text @d4 3 d21 1 a21 1 ... a31 4 RcsId("$Header: RCS/gram.y,v 1.63 90/04/17 21:25:48 goh Exp Locker: goh $"); #include d42 2 a45 1 #define MAXPATHLEN 1024 d60 3 a62 1 static ResdomNoIsAttrNo = 0; d79 1 a79 1 static Relation CurrentRelationPtr = NULL; d200 1 a200 1 Cluster Relation On index_name OptUseOp d395 1 a395 12 def_type: Function { $$ = KW(function); } | Operator { $$ = KW(operator); } | Type { $$ = KW(type); } ; def_name: Id | Op ; d397 2 d400 1 a400 1 ARG Is '(' def_name_list ')' d452 1 a452 1 Fetch opt_direction fetch_how_many opt_portal_name d457 1 a457 1 $$ = lispCons ( $1 , $4 ); d477 1 a477 1 Move opt_direction opt_move_where opt_portal_name d482 1 a482 1 $$ = lispCons ( $1 , $4 ); d522 1 a522 1 Define opt_archive Index index_name On relation_name d548 1 a548 1 MERGE Relation Into relation_name d602 1 a602 1 (REMOVE OPERATOR "opname") d668 11 d680 1 a680 1 Define newruleTag Rule name Is d688 2 a689 1 $4 = lispCons ( $4, $7 ); d708 1 d755 12 a766 12 Abort TRANSACTION { $$ = lispCons ( $1, LispNil ) ; } | Begin TRANSACTION { $$ = lispCons ( $1, LispNil ) ; } | End TRANSACTION { $$ = lispCons ( $1, LispNil ) ; } | Abort { $$ = lispCons ( $1, LispNil ) ; } | Begin { $$ = lispCons ( $1, LispNil ) ; } | End { $$ = lispCons ( $1, LispNil ) ; } d828 2 a829 2 CurrentRelationPtr = amopenr(VarnoGetRelname(x)); if (CurrentRelationPtr == NULL) d831 1 a831 1 ResdomNoIsAttrNo = 1; d853 1 a853 1 ResdomNoIsAttrNo = 0; d883 2 a884 2 CurrentRelationPtr = amopenr(VarnoGetRelname(x)); if (CurrentRelationPtr == NULL) d886 1 a886 1 ResdomNoIsAttrNo = 1; d956 1 a956 1 CurrentRelationPtr = amopenr(VarnoGetRelname(x)); d958 1 a958 1 if (CurrentRelationPtr == NULL) d960 1 a960 1 ResdomNoIsAttrNo = 1; } d982 1 a982 1 ResdomNoIsAttrNo = 0; d1044 1 a1044 1 Into relation_name d1296 1 a1296 1 b_expr And boolexpr d1299 1 a1299 1 | b_expr Or boolexpr d1304 1 a1304 1 | Not b_expr d1323 2 a1324 2 var_def: Id '=' typename d1326 5 a1330 2 $3 = lispCons($3,LispNil); $$ = lispCons($1,$3); d1332 1 a1332 1 | Id '=' typename '[' ']' d1334 8 a1341 2 $3 = lispCons($3,lispCons(lispInteger(-1),LispNil)); $$ = lispCons($1,$3); d1343 17 a1359 4 | Id '=' typename '[' Iconst ']' { $3 = lispCons($3,lispCons($5,LispNil)); $$ = lispCons($1,$3); d1363 7 d1386 13 d1429 1 a1429 1 | a_expr TYPECAST Id d1431 2 a1432 70 /* check for passing non-ints */ Const adt; Datum lcp; Type tp = type(CString($3)); int32 len = tlen(tp); char *cp = NULL; char *const_string = palloc(256); switch ( CInteger(CAR($1)) ) { case 23: /* int4 */ sprintf(const_string,"%d", get_constvalue(CDR($1))); break; case 19: /* char16 */ sprintf(const_string,"%s", get_constvalue(CDR($1))); break; case 18: /* char */ sprintf(const_string,"%c", get_constvalue(CDR($1))); break; case 701:/* float8 */ sprintf(const_string,"%f", get_constvalue(CDR($1))); break; case 25: /* text */ const_string = DatumGetPointer( get_constvalue(CDR($1)) ); break; default: elog(WARN,"unknown type%d ", CInteger(CAR($1)) ); } cp = instr2 (tp, const_string); if (!tbyvalue(tp)) { if (len >= 0 && len != PSIZE(cp)) { char *pp; pp = palloc(len); bcopy(cp, pp, len); cp = pp; } lcp = PointerGetDatum(cp); } else { switch(len) { case 1: lcp = Int8GetDatum(cp); break; case 2: lcp = Int16GetDatum(cp); break; case 4: lcp = Int32GetDatum(cp); break; default: lcp = PointerGetDatum(cp); break; } } adt = MakeConst ( typeid(tp), len, lcp , 0 ); /* printf("adt %s : %d %d %d\n",CString($1),typeid(tp) , len,cp); */ $$ = lispCons ( lispInteger (typeid(tp)) , adt ); d1439 8 d1449 4 d1487 1 a1487 1 if (ResdomNoIsAttrNo) { d1506 1 a1506 34 int type_id,type_len, attrtype, attrlen; int resdomno; Relation rd; type_id = CInteger(CAR($3)); type_len = tlen(get_id_type(type_id)); if (ResdomNoIsAttrNo) { /* append or replace query */ /* append, replace work only on one relation, so multiple occurence of same resdomno is bogus */ rd = CurrentRelationPtr; Assert(rd != NULL); resdomno = varattno(rd,CString($1)); attrtype = att_typeid(rd,resdomno); attrlen = tlen(get_id_type(attrtype)); if (attrtype != type_id) elog(WARN, "unequal type in tlist : %s \n", CString($1)); if( lispAssoc( lispInteger(resdomno),p_target_resnos) != -1 ) { elog(WARN,"two or more occurence of same attr"); } else { p_target_resnos = lispCons( lispInteger(resdomno), p_target_resnos); } } else { resdomno = p_last_resno++; attrtype = type_id; attrlen = type_len; } $$ = (LispValue)lispCons (MakeResdom (resdomno, attrtype, attrlen , CString($1), 0 , 0 ) , lispCons((Var)CDR($3),LispNil)); a1545 1 typename: Id /*$$=$1*/ d1583 6 a1588 1 { if (QueryIsRule) $$ = yylval; else elog(WARN,"parser"); } d1590 6 a1595 1 { if (QueryIsRule) $$ = yylval; else elog(WARN,"parser"); } a1597 1 Abort: ABORT_TRANS { $$ = yylval ; } ; a1599 1 And: AND { $$ = yylval ; } ; a1601 1 Begin: BEGIN_TRANS { $$ = yylval ; } ; a1608 2 End: END_TRANS { $$ = yylval ; } ; Fetch: FETCH { $$ = yylval ; } ; a1612 2 Into: INTO { $$ = yylval ; } ; Is: IS { $$ = yylval ; } ; a1613 1 Move: MOVE { $$ = yylval ; } ; a1614 2 Not: NOT { $$ = yylval ; } ; On: ON { $$ = yylval ; } ; a1615 1 Or: OR { $$ = yylval ; } ; a1628 1 d1642 1 a1642 1 ResdomNoIsAttrNo = 0; d1646 5 a1650 3 char * expand_file_name(file) char *file; d1652 22 a1673 10 char *str; int ind; str = (char *) palloc(MAXPATHLEN * sizeof(*str)); str[0] = '\0'; if (file[0] == '~') { if (file[1] == '\0' || file[1] == '/') { /* Home directory */ strcpy(str, getenv("HOME")); ind = 1; d1675 2 a1676 21 /* Someone else's directory */ char name[16], *p; struct passwd *pw; int len; if ((p = (char *) index(file, '/')) == NULL) { strcpy(name, file+1); len = strlen(name); } else { len = (p - file) - 1; strncpy(name, file+1, len); name[len] = '\0'; } /*printf("name: %s\n");*/ if ((pw = getpwnam(name)) == NULL) { elog(WARN, "No such user: %s\n", name); ind = 0; } else { strcpy(str, pw->pw_dir); ind = len + 1; } d1679 3 a1681 1 ind = 0; d1683 6 a1688 29 strcat(str, file+ind); return(str); } LispValue new_filestr ( filename ) LispValue filename; { return (lispString (expand_file_name (CString(filename)))); } int lispAssoc ( element, list) LispValue element, list; { LispValue temp = list; int i = 0; if (list == LispNil) return -1; /* printf("Looking for %d", CInteger(element));*/ while (temp != LispNil ) { if(CInteger(CAR(temp)) == CInteger(element)) return i; temp = CDR(temp); i ++; } return -1; @ 1.63 log @fixes the from clause bug with inheritance at the (temporary) expense of causing a "bogus" shift/reduce conflict which is always handled correctly anyway (shift only if we see a '*') @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.61 90/04/12 23:29:32 goh Exp Locker: goh $"); d1250 1 a1250 1 '[' opt_date ',' opt_date ']' d1269 7 a1275 1 opt_date: @ 1.62 log @fixed latest from list bug ... nasty token munging by yacc. @ text @d684 1 a684 1 $3 = lispCons ( $4, $7 ); d1216 1 a1216 1 relation_name opt_time_range star d1233 1 a1233 1 | relation_name opt_time_range %PREC REDUCE d1523 2 a1524 1 elog(WARN, "unequal type in tlist\n"); @ 1.61 log @fixes the _REAL_ typecasting bug ... also needs scan.lex and lib/H/parse.h @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.59 90/03/14 10:46:33 goh Exp Locker: goh $"); d683 3 a685 1 $3 = lispCons ( $3, $7 ); d771 1 a771 1 Define VIEW name { SkipForwardToFromList(); } d774 1 a774 1 $3 = lispCons ( $3 , $5 ); a994 1 { SkipForwardToFromList(); } d996 1 a996 1 { $$ = $3 ; } d1000 1 d1012 1 a1012 1 if ( $2 == LispNil ) d1017 2 a1018 2 root = MakeRoot(NumLevels,command, $3, p_rtable, p_priority, p_ruleinfo,$4,$9,$6); d1022 2 a1023 2 $$ = nappend1 ( $$ , $6 ); /* (eq p_target $8) */ $$ = nappend1 ( $$ , $8 ); /* (eq p_qual $10) */ @ 1.60 log @misc bug fixes, including greg's box-bug fix. @ text @d96 1 a96 1 UNION UNIQUE USING WHERE WITH FUNCTION OPERATOR P_TYPE d106 1 a106 1 REWRITE P_TUPLE d117 1 a117 1 %right ':' d1373 1 a1373 1 | a_expr ':' ':' Id d1378 1 a1378 1 Type tp = type(CString($4)); d1396 1 a1396 1 case 700:/* float4 */ d1450 1 a1450 1 { $$ = make_const ( $2, $1 , $3 ); } @ 1.59 log @fixes append bug with make root @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.58 90/03/13 18:32:04 goh Exp Locker: goh $"); d169 1 a169 1 Addattr '(' dom_list ')' TO relation_name d199 1 d222 15 a236 15 LispValue temp; $$ = lispCons($1,LispNil); $4 = lispCons($4,LispNil); $4 = nappend1($4,$2); $4 = nappend1($4,$3); $$ = nappend1($$,$4); $$ = nappend1($$,lispCons ($8,lispCons($9,LispNil))); if(! lispNullp($10)) $10 = lispCons($10,LispNil); $$ = nappend1($$, lispCons(KW(using), $10)); temp = $$; while(temp != LispNil && CDR(temp) != LispNil ) temp = CDR(temp); CDR(temp) = $6; /* $$ = nappend1 ($$ , $6 ); /* copy_list */ d303 1 a303 1 Create relation_name '(' opt_dom_list ')' d369 1 a369 1 dom_name OptUseOp d445 1 d459 1 a459 1 Fetch OptFetchDirn OptFetchNum OptFetchPname d468 1 a468 10 OptFetchDirn: /*EMPTY, default is forward*/ { $$ = KW(forward); } | BACKWARD { $$ = KW(backward); } | FORWARD { $$ = KW(forward); } ; OptFetchNum: d476 26 a501 1 OptFetchPname: d503 5 a507 1 | In name { $$ = $2; } d510 7 d532 3 a563 14 QUERY: move [] [] [] TREE: ( MOVE ["portalname"] (TO | **********************************************************************/ MoveStmt: Move opt_move_dirn opt_move_where opt_move_pname { $3 = lispCons ( $3 , LispNil ); $2 = lispCons ( $2 , $3 ); $4 = lispCons ( $4 , $2 ); $$ = lispCons ( $1 , $4 ); } ; a564 25 opt_move_dirn: /*EMPTY, by default forward */ { $$ = KW(forward); } | FORWARD { $$ = KW(forward); } | BACKWARD { $$ = KW(backward); } ; opt_move_where: /*EMPTY*/ { NULLTREE } | NumConst /* $$ = $1 */ | TO NumConst { $$ = lispCons ( KW(to) , lispCons( $2, LispNil )); } | TO record_qual { $$ = lispString("record quals unimplemented") ; } ; opt_move_pname: /*EMPTY*/ { NULLTREE } | In name { $$ = $2;} ; /********************************************************************** d655 1 a655 1 RENAME att_name In relation_name TO att_name d676 1 a676 11 Define Rule name opt_priority Is rule_tag { p_ruleinfo = lispCons(lispInteger(0),$6); p_priority = $4; } OptimizableStmt { $3 = lispCons($3,LispNil); /* name */ $2 = lispCons($2,$3); /* rule */ $$ = lispCons($1,$2); /* define */ $$ = nappend1($$,$8 ); /* rule query */ } | Define newruleTag Rule name Is d683 3 a685 4 $$ = lispCons ( $3, $6 ); /* CADR(args) = CADDR(tree) = name */ $$ = lispCons ( $2, $$ ); /* tag = CADR(tree) = 'rule */ $$ = lispCons ( $1, $$ ); /* CAR(tree) = 'define */ a688 15 rule_tag: ALWAYS { $$ = KW(always); } | ONCE { $$ = KW(once); } | NEVER { $$ = KW(never); } ; opt_priority: /*EMPTY*/ { $$ = lispInteger(0); } | PRIORITY Iconst { $$ = $2 ; } ; d693 2 d714 1 a714 1 relation_name '.' att_name d1083 1 a1083 1 dom_name opt_class d1152 1 a1152 1 var_list In from_rel_name a1299 1 opt_dom_list: dom_list | {NULLTREE} ; d1301 7 a1307 4 dom_list: dom_list ',' dom { INC_LIST ; } | dom { ELEMENT ; } ; d1309 2 a1310 2 dom: dom_name '=' adt d1315 10 d1326 15 a1355 1 /* | AexprConst ':' ':' adt_name */ d1404 1 d1454 1 a1454 1 relation_name '.' att_name d1570 1 a1570 1 att_name: Id /*$$=$1*/; a1572 1 dom_name: Id /*$$=$1*/; d1578 1 a1578 1 adt: Id /*$$=$1*/; a1637 1 In: IN { $$ = yylval ; } ; @ 1.58 log @another fix @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.56 90/03/12 13:51:59 goh Exp Locker: goh $"); d871 2 a872 1 p_priority, p_ruleinfo); d930 2 a931 1 p_rtable, p_priority, p_ruleinfo); d999 2 a1000 1 p_priority, p_ruleinfo); @ 1.57 log @added the "<" and ">" operators to the sort by clause. temporary bandaid until all operators are properly accessed @ text @d1232 2 a1233 2 | USING '<' { $$ = $2; } | USING '>' { $$ = $2; } @ 1.56 log @first integration checkin @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.55 89/09/21 18:48:57 hirohama Exp $"); d1232 2 a1233 2 | USING Op { $$ = $2; } | USING Id { $$ = $2; } @ 1.55 log @palloc now defined in "palloc.h" @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.54 89/09/19 10:57:33 goh Exp Locker: hirohama $"); d53 1 a53 1 #define INC_NUM_LEVELS(x) if (NumLevels < x ) NumLevels = x; d56 2 d105 2 a106 1 %token INHERITANCE VERSION CURRENT NEW ON THEN DO INSTEAD a107 3 d109 6 a114 4 %right '=' %left '+' '-' %left '*' '/' %left '(' ')' '[' ']' d116 3 d122 11 a134 2 { $$ = $1; parsetree=$$; } | experiment a136 30 experiment: ON RETRIEVE TO relation_name opt_qual THEN DO opt_instead { QueryIsRule = true; } OptimizableStmt { HandleRetrieveRuleDef(CString($4),$5,$7,$10); } | ON REPLACE TO relation_name opt_qual THEN DO opt_instead { QueryIsRule = true; } OptimizableStmt { HandleReplaceRuleDef($2,$4,$5,$7,$10); } ; opt_qual: { NULLTREE } ; opt_instead: INSTEAD | /* EMPTY */ { NULLTREE } ; d156 2 a157 1 | TransactionStmt d279 1 a279 1 | equals Id { $$ = $2 ; } d341 1 a341 1 | Archive equals archive_type {$$ = lispCons ($1 , $3); } d427 1 a427 1 def_name equals def_arg d489 25 d559 1 a559 1 { $$ = lispCons ( KW($1) , lispCons( $2, LispNil )); } d678 3 d682 24 a705 6 /************************************************** Rules: define rule is (DEFINE RULE "rulename" (rulequery)) d707 8 a714 4 - is one of always,never,once - is between 0 and 7 - is one of 5 query stmts (retrieve,replace,append,execute) d716 4 a719 1 **************************************************/ d721 5 a725 11 RuleStmt: Define Rule name opt_priority Is rule_tag { p_ruleinfo = lispCons(lispInteger(0),$6); p_priority = $4; } OptimizableStmt { $3 = lispCons($3,LispNil); /* name */ $2 = lispCons($2,$3); /* rule */ $$ = lispCons($1,$2); /* define */ $$ = nappend1($$,$8 ); /* rule query */ } d728 14 a741 7 rule_tag: ALWAYS { $$ = KW(always); } | ONCE { $$ = KW(once); } | NEVER { $$ = KW(never); } d744 11 a754 3 opt_priority: /*EMPTY*/ { $$ = lispInteger(0); } | PRIORITY Iconst { $$ = $2 ; } d757 8 a790 2 /************************************************************ d792 1 a792 5 define index: define [archive] index on using "(" ( with )+ ")" with d794 2 a795 1 ************************************************************/ d797 1 d799 7 a805 11 IndexStmt: Define opt_archive Index index_name On relation_name Using access_method '(' index_list ')' with_clause { $12 = lispCons($12,LispNil); $10 = lispCons($10,$12); $8 = lispCons($8,$10); $4 = lispCons($4,$8); $6 = lispCons($6,$4); $3 = lispCons($3,$6); $$ = lispCons($1,$3); a808 1 d845 4 a848 3 if((x=RangeTablePosn(CString($5),0,0)) == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry (CString($5),0,CString($5))); d850 1 a850 1 x = RangeTablePosn(CString($5),0,0); d860 2 a861 1 int x = RangeTablePosn(CString($5),0,0); d863 7 a869 1 root = MakeRoot(1, KW(append), lispInteger(x), d895 15 a909 10 int x = 0; if((x=RangeTablePosn(CString($5),0,0)) == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry (CString($5),0,CString($5))); if (x==0) x = RangeTablePosn(CString($5),0,0); CurrentRelationPtr = amopenr(VarnoGetRelname(x)); if (CurrentRelationPtr == NULL) elog(WARN,"invalid relation name"); ResdomNoIsAttrNo = 1; } d912 24 a935 14 LispValue root; int x; x= RangeTablePosn(CString($5),0,0); if (x == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry (CString($5),0,CString($5))); StripRangeTable(); root = MakeRoot(NumLevels,KW(delete), lispInteger ( x ) , p_rtable, p_priority, p_ruleinfo); $$ = lispCons ( root , LispNil ); /* check that var_name is in the relation */ $$ = nappend1 ( $$ , LispNil ); /* (eq p_target $5) */ $$ = nappend1 ( $$ , $7 ); /* (eq p_qual $7 */ d951 1 a951 1 $$ = KW($1); d971 4 a974 3 if((x=RangeTablePosn(CString($5),0,0)) == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry (CString($5),0,CString($5))); d976 1 a976 1 x = RangeTablePosn(CString($5),0,0); d985 2 a986 1 int result = RangeTablePosn(CString($5),0,0); d990 6 a995 1 root = MakeRoot(1, KW(replace), lispInteger(result), d1020 1 a1020 1 RETRIEVE d1022 5 d1035 2 a1036 1 d1038 4 a1041 2 root = MakeRoot(NumLevels,KW(retrieve), $5, p_rtable, p_priority, p_ruleinfo); d1043 4 d1048 2 a1049 2 $$ = nappend1 ( $$ , p_target ); /* (eq p_target $8) */ $$ = nappend1 ( $$ , $10 ); /* (eq p_qual $10) */ d1078 1 a1078 1 { $$ = KW($1); } d1121 1 a1121 1 Op d1159 1 a1159 1 Id equals string d1189 1 a1189 1 temp = CDR(temp); /* move to last elt */ d1199 1 a1199 1 p_rtable = nappend1(p_rtable,temp3); d1238 1 a1238 1 | le_op Iconst gt_op { $$ = $2; } d1242 1 a1242 1 relation_name opt_time_range opt_star d1244 1 a1244 4 int inherit_flag = 0; int trange_flag = (int)$2; printf("timerange flag = %d",(int)$2); d1246 12 a1257 7 if ($3 != LispNil ) /* inheritance query*/ inherit_flag = 1; if( !RangeTablePosn(CString($1),inherit_flag,p_trange)) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry (CString($1), inherit_flag | trange_flag, CString($1) )); d1259 14 d1277 5 a1281 2 { printf ("time range\n");fflush(stdout); p_trange = MakeTimeRange($2,$4,1); $$ = (LispValue)2; } d1283 5 a1287 2 { printf("snapshot\n"); fflush(stdout); p_trange = MakeTimeRange($2,LispNil,0); $$ = (LispValue)2; } d1289 4 a1292 1 { p_trange = lispInteger(0); $$ = lispInteger(0); } d1294 1 d1336 1 a1336 1 dom_name equals adt d1349 7 d1357 20 a1376 2 | adt_name '[' adt_const ']' { d1380 1 a1380 1 Type tp = type(CString($1)); d1382 2 a1383 1 char *cp = instr2 (tp, CString($3)); d1385 29 d1445 1 a1446 9 | spec | a_expr Op a_expr { $$ = make_op ($2, $1, $3 ) ; } | a_expr Op { $$ = make_op($2,LispNil, $1); } | Op a_expr { $$ = make_op($1,$2, LispNil); } d1450 2 a1453 22 equals: Op {if (strcmp(CString(yylval), "=") != 0) { yyerror("syntax error (expected '=')"); /*YYABORT;*/ } } le_op: Op { if (strcmp(CString(yylval), "<") != 0) { yyerror("syntax error ('<' should be used)"); /*YYABORT;*/ } } gt_op: Op {if (strcmp(CString(yylval), ">") != 0) { yyerror("syntax error ('>' should be used)"); /*YYABORT;*/ } } d1458 4 a1461 4 if( RangeTablePosn ( CString ($1),0,0 ) == 0 ) p_rtable = nappend1 (p_rtable , MakeRangeTableEntry( CString($1) , 0, CString($1))); d1505 1 a1505 1 Id equals a_expr d1584 1 a1584 1 adt_const: Sconst /*$$=$1*/; @ 1.54 log @fixes for define rule from lisp-tree propagated over. @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.52 89/09/15 11:49:25 goh Exp Locker: goh $"); d32 1 d35 1 d37 2 a40 2 #include "parse_query.h" #include @ 1.53 log @got rid of dotted list for PURGE @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.52 89/09/15 11:49:25 goh Exp Locker: hirohama $"); d566 1 a566 1 (PURGE "relname" ((BEFORE date) (AFTER date))) d592 4 a595 2 before_clause: BEFORE date { $$ = lispCons($1, cons($2, LispNil)); } ; after_clause: AFTER date { $$ = lispCons($1, cons($2, LispNil)); } ; d684 1 d690 1 a690 1 $$ = nappend1($$,$7 ); /* rule query */ @ 1.52 log @aargh, left out a paren last time. teach me to try to be smart. @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.49 89/09/14 17:55:46 goh Exp $"); d566 1 a566 1 (PURGE "relname" ((BEFORE . date)(AFTER . date))) d592 2 a593 2 before_clause: BEFORE date { $$ = lispCons($1,$2); } ; after_clause: AFTER date { $$ = lispCons($1,$2); } ; @ 1.51 log @more "correct" fix for cim's problem. Hope changing to a datum doesn't break any other code. @ text @d1262 1 @ 1.50 log @changed to fix cim's problem with indexscans @ text @d1235 1 a1235 1 LispValue lcp; d1241 7 a1247 7 if (len >= 0 && len != PSIZE(cp)) { char *pp; pp = palloc(len); bcopy(cp, pp, len); cp = pp; } lcp = parser_ppreserve(cp); d1249 13 a1261 1 lcp = cp; @ 1.49 log @minor fix for PRS 2 @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.48 89/09/10 18:46:02 hirohama Exp Locker: goh $"); d1249 1 a1249 1 lcp = lispInteger((long) cp); @ 1.48 log @for some reason the (semantically equivalent) previous version would cause yacc to generate a file on which cpp would die on "postgres" @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.47 89/09/10 17:10:27 hirohama Exp Locker: hirohama $"); d129 1 a129 1 HandleRetrieveRuleDef(parsetree,$4,$5,$7); d138 1 a138 1 HandleReplaceRuleDef(parsetree,$2,$4,$5,$7); @ 1.47 log @fixed "USING" clause for "COPY" @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.46 89/09/05 16:51:15 mao C_Demo_1 Locker: hirohama $"); d261 1 a261 2 | Using map_rel_name { $$ = $2; } @ 1.46 log @Working version of C-only demo @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.45 89/08/31 14:15:02 goh Exp $"); d219 1 a219 1 [USING d262 1 a262 1 { $$ = lispCons ($2 , LispNil ); } @ 1.45 log @oops, varnogetrelname now returns name @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.43 89/08/31 10:48:02 goh Exp $"); @ 1.44 log @more fixes (sigh, forgot about the CString bug) @ text @d903 1 a903 2 CurrentRelationPtr = amopenr(CString(VarnoGetRelname(x))); printf("relation is %s\n",CString(VarnoGetRelname(x))); @ 1.43 log @major fixes for replace,append,delete that were made to distribution gram.y, now propagated here @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.39 89/08/25 11:13:12 goh Exp Locker: goh $"); d797 1 a797 1 ($5,0,$5)); d840 1 a840 1 ($5,0,$5)); d854 1 a854 1 ($5,0,$5)); d900 1 a900 1 ($5,0,$5)); a1469 1 Append: APPEND { $$ = yylval ; } ; a1478 1 Delete: DELETE { $$ = yylval ; } ; @ 1.42 log @fixed FETCH to use KW() for "forward," "backward," and "all" @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.41 89/08/29 13:10:57 hirohama Exp Locker: hirohama $"); d483 3 a485 1 | Forward a486 2 | Backward { $$ = KW(backward); } d492 2 a493 1 | All a494 1 | NumConst d527 1 a527 1 Move OptFetchDirn opt_move_where opt_move_pname d536 8 d789 31 a819 12 Append opt_star relation_name { CurrentRelationPtr = amopenr(CString($3)); ResdomNoIsAttrNo = 1; SkipForwardToFromList(); if(RangeTablePosn(CString($3),0,0) == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry (CString($3),0,CString($3))); } from_clause '(' res_target_list ')' where_clause { LispValue root; a820 10 StripRangeTable(); root = MakeRoot(1, KW(append), lispInteger(1), p_rtable, p_priority, p_ruleinfo); $$ = lispCons ( root , LispNil ); $$ = nappend1 ( $$ , $7 ); /* (eq p_target $5) */ $$ = nappend1 ( $$ , $9 ); /* (eq p_qual $8 */ ResdomNoIsAttrNo = 0; } ; d832 33 a864 19 Delete { SkipForwardToFromList(); } from_clause opt_star var_name where_clause { LispValue root; if(RangeTablePosn(CString($5),0,0) == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry (CString($5),0,CString($5))); StripRangeTable(); root = MakeRoot(NumLevels,KW(delete), lispInteger ( 1 ) , p_rtable, p_priority, p_ruleinfo); $$ = lispCons ( root , LispNil ); /* check that var_name is in the relation */ $$ = nappend1 ( $$ , LispNil ); /* (eq p_target $5) */ $$ = nappend1 ( $$ , $6 ); /* (eq p_qual $5 */ } ; d893 26 a918 16 { SkipForwardToFromList(); } from_clause opt_star relation_name { int x = 0; if((x=RangeTablePosn(CString($5),0,0)) == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry (CString($5),0,CString($5))); if (x==0) x = 1; CurrentRelationPtr = amopenr(VarnoGetRelname(x)); if (CurrentRelationPtr == NULL) elog(WARN,"invalid relation name"); ResdomNoIsAttrNo = 1; } '(' res_target_list ')' where_clause { LispValue root; d920 6 a925 4 StripRangeTable(); root = MakeRoot(1, KW(replace), lispInteger(1), p_rtable, p_priority, p_ruleinfo); d927 1 a927 6 $$ = lispCons( root , LispNil ); $$ = nappend1 ( $$ , $8 ); /* (eq p_target $6) */ $$ = nappend1 ( $$ , $10 ); /* (eq p_qual $9) */ ResdomNoIsAttrNo = 0; } ; d1134 2 a1135 2 $2 = lispCons($2, LispNil); $$ = lispCons(KW(portal), $2); a1472 1 Backward: BACKWARD { $$ = yylval ; } ; a1483 1 Forward: FORWARD { $$ = yylval ; } ; @ 1.41 log @make optional_portal return '(portal "pname") instead of '(317 "pname") @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.40 89/08/28 18:38:32 hirohama Exp Locker: hirohama $"); d483 2 d486 1 a486 1 | Forward d492 2 a494 1 | All d527 1 a527 1 Move opt_move_dirn opt_move_where opt_move_pname a533 6 ; opt_move_dirn: /*EMPTY, by default forward */ { $$ = KW(forward); } | Forward /* $$ = $1 */ | Backward /* $$ = $1 */ @ 1.40 log @KW(relation) -> KW(into) @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.39 89/08/25 11:13:12 goh Exp Locker: hirohama $"); d1099 2 a1100 2 $2=lispCons($2,LispNil); $$=lispCons($1,$2); @ 1.39 log @cleaned up bunch o' stuff @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.38 89/08/22 18:23:30 hirohama Exp Locker: goh $"); d930 1 a930 1 (RELATION "relname"); d942 1 a942 1 $$=lispCons(KW(relation), $2); @ 1.38 log @continuation of fix to REMOVE OPERATOR @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.37 89/08/22 17:03:58 hirohama Exp Locker: hirohama $"); d74 1 d76 1 d81 3 a83 3 %token ABORT_TRANS ADD_ATTR APPEND ATTACH_AS BEGIN_TRANS CLOSE CLUSTER COPY CREATE DEFINE DELETE DESTROY END_TRANS EXECUTE FETCH MERGE MOVE PURGE REMOVE RENAME REPLACE RETRIEVE d87 6 a92 6 %token ALL ALWAYS AFTER AND ARCHIVE ARG ASCENDING BACKWARD BEFORE BINARY BY DEMAND DESCENDING EMPTY FORWARD FROM HEAVY INTERSECT INTO IN INDEX INDEXABLE INHERITS INPUTPROC IS KEY LEFTOUTER LIGHT MERGE NEVER NEWVERSION NONE NONULLS NOT PNULL ON ONCE OR OUTPUTPROC PORTAL PRIORITY QUEL RIGHTOUTER RULE SCONST SORT TO TRANSACTION UNION UNIQUE USING WHERE WITH FUNCTION OPERATOR P_TYPE d94 1 d99 7 d122 19 a140 2 a_expr { parsetree = $1; }; d142 9 d182 1 a182 1 Addattr '(' dom_list ')' To relation_name d252 6 a257 1 copy_dirn: To | From ; d358 5 a362 1 archive_type: Heavy | Light | None ; d420 1 a420 1 Arg Is '(' def_name_list ')' a441 3 /* { $$ = lispCons ( lispAtom(CString($1)) , */ /* lispCons ($3, LispNil)); } */ a443 1 /* { $$ = lispCons(lispAtom(CString($1)), LispNil); } */ d496 1 a496 1 | In portal_name { $$ = $2; } d509 1 a509 1 Merge Relation Into relation_name d542 3 a544 3 | To NumConst { $$ = lispCons ( $1 , lispCons( $2, LispNil )); } | To record_qual d550 1 a550 1 | In portal_name { $$ = $2;} d644 1 a644 1 RENAME att_name In relation_name To att_name d651 1 a651 1 | RENAME relation_name To relation_name d687 8 a694 1 rule_tag: Always | Once | Never ; d714 1 a714 1 Abort Transaction d716 1 a716 1 | Begin Transaction d718 1 a718 1 | End Transaction d847 1 a847 1 Execute opt_star opt_portal '(' res_target_list ')' d850 1 a850 1 $$ = $1; d864 1 a864 1 Replace a893 3 opt_rep_duration: /*EMPTY*/ {NULLTREE} | Demand | Always ; d906 1 a906 1 Retrieve d951 2 a952 1 | Unique d958 1 a958 1 | Sort By sortby_list d975 1 a975 1 {$$=LispNil;} d1038 3 a1040 1 From from_list { $$ = $2 ; d1044 1 a1044 1 } d1097 1 a1097 1 | Portal portal_name d1106 2 a1107 2 | Using Op { $$ = $2; } | Using Id { $$ = $2; } d1372 5 a1376 1 relation_name: Id /*$$=$1*/; a1384 1 portal_name: Id /*$$=$1*/; d1424 5 a1428 3 /* | Keyword { extern char yytext[]; $$ = lispString( yytext ); } /* XXX - may not be good */ a1429 5 /* Keyword: Sort | Before ;*/ a1432 1 After: AFTER { $$ = yylval ; } ; a1433 1 Always: ALWAYS { $$ = yylval ; } ; a1436 2 Arg: ARG { $$ = yylval ; } ; Ascending: ASCENDING { $$ = yylval ; } ; a1438 1 Before: BEFORE { $$ = yylval ; } ; a1440 1 By: BY { $$ = yylval ; } ; a1446 2 Demand: DEMAND { $$ = yylval ; } ; Descending: DESCENDING { $$ = yylval ; } ; a1447 1 Empty: EMPTY { $$ = yylval ; } ; a1448 1 Execute: EXECUTE { $$ = yylval ; } ; a1450 1 From: FROM { $$ = yylval ; } ; a1451 1 Heavy: HEAVY { $$ = yylval ; } ; a1455 2 Input_proc: INPUTPROC { $$ = yylval ; } ; Intersect: INTERSECT { $$ = yylval ; } ; a1458 3 Leftouter: LEFTOUTER { $$ = yylval ; } ; Light: LIGHT { $$ = yylval ; } ; Merge: MERGE { $$ = yylval ; } ; a1459 2 Never: NEVER { $$ = yylval ; } ; None: NONE { $$ = yylval ; } ; a1462 1 Once: ONCE { $$ = yylval ; } ; a1464 1 Output_proc: OUTPUTPROC { $$ = yylval ; } ; a1465 1 Priority: PRIORITY { $$ = yylval ; } ; a1466 1 Quel: QUEL { $$ = yylval ; } ; a1467 4 Rename: RENAME { $$ = yylval ; } ; Replace: REPLACE { $$ = yylval ; } ; Retrieve: RETRIEVE { $$ = yylval ; } ; Rightouter: RIGHTOUTER { $$ = yylval ; } ; a1469 1 To: TO { $$ = yylval ; } ; a1470 3 Transaction: TRANSACTION { $$ = yylval ; } ; Union: UNION { $$ = yylval ; } ; Unique: UNIQUE { $$ = yylval ; } ; d1493 1 @ 1.36 log @fixed REMOVE OPERATOR @ text @d30 1 a30 1 RcsId("$Header: RCS/gram.y,v 1.35 89/08/18 12:14:34 hirohama Exp Locker: hirohama $"); d578 1 a578 1 Remove Operator name '(' remove_operator ')' d587 1 a587 1 Id d589 2 a590 2 | Id ',' Id { $$ = lispCons($1, lispCons($2, LispNil)); } @ 1.35 log @fixed def_elem to return list of one string instead of list of one symbol @ text @d30 1 a30 1 RcsId("$Header: /n/hermes/usr6/postgres/hirohama/postgres/src/parser/RCS/gram.y,v 1.34 89/08/16 20:37:27 hirohama Exp Locker: hirohama $"); d125 1 a125 1 | IndexStmt d129 1 a410 3 d575 18 a592 1 Function | Rule | Operator | Type | Index ; @ 1.34 log @fixed KW(UPPER_CASE) usage to KW(correct_spelling) fixed def_elem to return list of two strings instead of (symbol string) @ text @d30 1 a30 1 RcsId("$Header$"); d401 2 a402 1 { $$ = lispCons(lispAtom(CString($1)), LispNil); } @ 1.33 log @fixes for inheritance @ text @a2 1 static char *gram_y ="$Header: /n/postgres/a/postgres/goh/postgres/src/parser/RCS/gram.y,v 1.32 89/08/04 13:16:32 goh Exp $"; d28 4 d52 1 a52 1 #define KW(keyword) lispAtom("keyword") d206 1 a206 1 $$ = nappend1 ($$ , lispCons( KW(USING),$10 )); d362 1 a362 1 { $$ = KW(FUNCTION); } d364 1 a364 1 { $$ = KW(OPERATOR); } d366 1 a366 1 { $$ = KW(TYPE); } d375 1 a375 1 { $$ = lispCons (KW(args), $4); } d396 4 a399 2 { $$ = lispCons ( lispAtom(CString($1)) , lispCons ($3, LispNil)); } d442 1 a442 1 { $$ = KW(FORWARD); } d449 1 a449 1 { $$ = KW(ALL) ; } d494 1 a494 1 /*EMPTY, by default forward */ { $$ = KW(FORWARD); } d881 1 a881 1 $$=lispCons( KW(RELATION) , $2 ); @ 1.32 log @changed the parser AND/OR/NOT to be integers (atoms) instead of strings @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.31 89/07/31 11:43:40 goh Locked $"; d1072 1 a1072 1 { p_trange = LispNil; $$ = (LispValue)0; } d1076 1 a1076 1 { $$ = LispNil; } @ 1.31 log @changed to use the stuff in the "nodes" package, notably, uses MakeParam instead of lisp_make_param() @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.30 89/07/25 16:49:58 goh Locked $"; d1090 1 a1090 1 { $$ = lispCons ( lispString ("AND") , lispCons($1 , d1093 1 a1093 1 { $$ = lispCons ( lispString ("OR") , lispCons($1 , d1098 1 a1098 1 { $$ = lispCons ( lispString ("NOT") , d1216 1 a1216 1 p_target = ExpandAll($1, &p_last_resno); d1220 1 a1220 1 CDR(temp) = ExpandAll( $1, &p_last_resno); d1233 1 a1233 1 p_target = ExpandAll($3, &p_last_resno); d1237 1 a1237 1 CDR(temp) = ExpandAll( $3, &p_last_resno); @ 1.30 log @lisp port, works till "retrieve (pg_relation.relname)" @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.28 89/03/31 02:26:40 goh Locked $"; d32 2 d720 1 a720 1 ($3,0,$3)); d757 1 a757 1 ($5,0,$5)); d803 1 a803 1 ($5,0,$5)); d1058 1 a1058 1 MakeRangeTableEntry ($1, d1060 1 a1060 1 $1 )); d1132 2 a1133 1 LispValue adt,lcp; d1199 2 a1200 1 MakeRangeTableEntry( $1 , 0, $1)); d1274 5 a1278 5 $$ = lispCons (MakeResdom ( resdomno, attrtype, attrlen , $1, 0 , 0 ) , lispCons (CDR($3) , LispNil) ); d1283 2 a1284 1 LispValue varnode, temp,resnode; d1292 1 a1292 1 CDR ( $1 ) , 0 , 0 ); d1294 1 a1294 1 $$ = lispCons (resnode, lispCons(varnode , LispNil ) ); d1325 1 a1325 1 { $$ = MakeParam( $4 ) ; } @ 1.29 log @*** empty log message *** @ text @d52 1 d1124 1 a1124 1 $$ = make_var ( CAR ($1) , CDR($1)); d1282 1 a1282 1 temp = make_var ( CAR($1) , CDR($1)); @ 1.28 log @fixed semantic checking for time ranges @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.27 89/03/30 18:14:45 hirohama Locked $"; d31 1 a31 1 #include "lispdep.h" d1047 1 a1047 1 int trange_flag = 0; d1049 2 a1050 13 if ($2 == LispNil ) { /* no time range */ p_trange = LispNil; trange_flag = 0; /* XXX a hack */ } else if (strcmp(CString(CAR($2)), "snapshot") == 0) { /* snapshot */ p_trange = MakeTimeRange( CDR($2), LispNil, 0); trange_flag = 2; } else { /* time range */ p_trange = MakeTimeRange( CAR($2), CDR($2), 1); trange_flag = 2; } d1063 2 a1064 1 { $$ = lispCons ($2,$4); } d1066 2 a1067 1 { $$ = lispCons(lispString("snapshot"),$2); } /* XXX a hack */ d1069 1 a1069 1 { NULLTREE } d1141 1 a1141 1 lcp = ppreserve(cp); d1146 1 a1146 1 adt = lispMakeConst ( typeid(tp), len, lcp , 0 ); d1269 1 a1269 1 $$ = lispCons (lispMakeResdom ( resdomno, d1284 1 a1284 1 resnode = lispMakeResdom ( p_last_resno++ , d1319 1 a1319 1 { $$ = lispMakeParam( $4 ) ; } @ 1.27 log @fixes for append statement to have tuple-var instead of a relation name and also time-range & inheiritance queries now follow relation-name [ timerange ] * as per manual @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.26 89/03/27 14:00:12 goh Locked $"; d1053 1 a1053 1 } else if ( !strcmp ( CString($2), "snapshot") ) { d1076 1 a1076 1 { $$ = lispCons(lispString("snapshot"),$2); } d1081 2 a1082 2 /* no date, default to lispint 0 */ { $$ = lispInteger(0); } @ 1.26 log @corrected fix for multi-occurence of same attr in append/replace @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.25 89/03/26 20:16:01 goh Locked $"; d235 5 a239 1 { $$ = lispCons ( $1, lispCons ($2, LispNil ) ); } d250 4 a253 1 | CCONST /* $$ = $1 */ d792 7 a798 2 Replace opt_star opt_rep_duration relation_name { if(RangeTablePosn(CString($4),0,0) == 0) d800 3 a802 2 ($4,0,$4)); CurrentRelationPtr = amopenr(CString($4)); d805 1 a805 2 SkipForwardToFromList(); ResdomNoIsAttrNo = 1; } from_clause d925 1 a925 1 Op d930 3 a932 4 /*EMPTY*/ { NULLTREE } | Op ; d1044 25 a1068 14 relation_name { if(RangeTablePosn(CString($1),0,0) == 0 ) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry( $1 , 0 ,$1)); $$ = p_rtable ; } | relation_name star { if(RangeTablePosn(CString($1),1,0) == 0 ) p_rtable = nappend1 (p_rtable , MakeRangeTableEntry( $1 , 1 ,$1)); $$ = p_rtable ;} | relation_name '[' date_string ']' { p_trange = MakeTimeRange( $3, LispNil ,0 ); /* snapshot */ if(RangeTablePosn(CString($1),0,p_trange) == 0 ) p_rtable = nappend1 (p_rtable , MakeRangeTableEntry( $1, 2,$1 )); $$ = p_rtable ; d1070 9 a1078 15 | relation_name '[' date ',' date ']' { /* inherit & timerange */ p_trange = MakeTimeRange( $3 , $5 , 1 ); if(RangeTablePosn(CString($1),0,p_trange) == 0 ) p_rtable = nappend1( p_rtable, MakeRangeTableEntry ( $1 , 2,$1 )); } | relation_name star '[' date ',' date ']' { p_trange = MakeTimeRange( $3 , $5 , 1 ); if(RangeTablePosn(CString($1),1,p_trange) == 0 ) p_rtable = nappend1( p_rtable, MakeRangeTableEntry ( $1 , 3 ,$1)); } d1080 5 a1084 4 a1197 7 date: date_string { $$ = $1; } | /*EMPTY, default to NOW*/ { $$ = lispInteger(0) ; } ; d1306 1 a1306 5 relation_name: Id ; d1321 1 a1321 1 date_string: Sconst /*$$=$1*/; d1519 1 a1519 1 printf("Looking for %d", CInteger(element)); @ 1.25 log @fixes to check for multiple occurence of same attribute for append/replace @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.24 89/03/26 00:06:29 goh Locked $"; d1257 1 a1257 1 == -1 ) { d1511 5 a1515 3 /* if (list == LispNil) return -1; */ while (! lispNullp (temp)) { @ 1.24 log @sigh, . . . more from list bug-fixes @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.23 89/03/25 01:36:53 goh Locked $"; d63 2 a64 1 p_rtable; d1221 4 d1246 3 a1248 1 if (ResdomNoIsAttrNo) { d1256 7 d1450 1 d1505 17 @ 1.23 log @fixed multiple from lists @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.22 89/03/24 10:32:37 goh Locked $"; d706 5 a710 1 ResdomNoIsAttrNo = 1; SkipForwardToFromList(); } d716 1 a716 3 if(RangeTablePosn(CString($3),0,0) == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry ($3,0,$3)); a796 4 if(RangeTablePosn(CString($4),0,0) == 0) p_rtable = nappend1 (p_rtable, MakeRangeTableEntry ($4,0,$4)); d1033 2 a1034 1 { p_rtable = nappend1 (p_rtable, d1037 2 a1038 1 { p_rtable = nappend1 (p_rtable , d1042 2 a1043 1 p_trange = MakeTimeRange( $3, LispNil ,0 ); /* snapshot */ d1045 1 a1045 1 MakeRangeTableEntry( $1, 2,$1 )); $$ = p_rtable ; d1051 1 d1057 2 a1058 1 p_trange = MakeTimeRange( $3 , $5 , 1 ); @ 1.22 log @1.21 didn't really do it for append this is the correct one. @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.21 89/03/24 10:27:25 goh Locked $"; d958 5 a962 1 From from_list { $$ = $2 ; } a994 3 SkipBackToTlist(); yychar = -1; /* goto yynewstate; */ @ 1.21 log @fixes for replace (with from_list) as reported by mike h and marti also, fixes for append (with from_list) (unreported, but related) @ text @d3 1 a3 1 static char *gram_y ="$Header: gram.y,v 1.20 89/03/22 15:06:16 goh Locked $"; d720 1 a720 1 $$ = nappend1 ( $$ , $8 ); /* (eq p_target $5) */ @ 1.20 log @oops, minor replace fix and also old bug (create) now fixed so that : "create foo () inherits (a,b)" now works @ text @d2 2 a3 1 static char *gram_y ="$Header: gram.y,v 1.19 89/03/22 10:12:47 goh Locked $"; d704 3 a706 2 Append { ResdomNoIsAttrNo = 1; SkipForwardToFromList(); } a707 2 opt_star relation_name { CurrentRelationPtr = amopenr(CString($5)); } d712 1 a712 1 if(RangeTablePosn(CString($5),0,0) == 0) d714 1 a714 1 ($5,0,$5)); d721 1 a721 1 $$ = nappend1 ( $$ , $10 ); /* (eq p_qual $8 */ d782 9 a790 5 Replace { SkipForwardToFromList(); ResdomNoIsAttrNo = 1; } from_clause opt_star opt_rep_duration var_name { CurrentRelationPtr = amopenr(CString($6)); } d795 1 a795 1 if(RangeTablePosn(CString($6),0,0) == 0) d797 1 a797 1 ($6,0,$6)); d800 1 a800 1 root = MakeRoot(NumLevels, KW(replace), lispInteger(1), d805 2 a806 2 $$ = nappend1 ( $$ , $9 ); /* (eq p_target $6) */ $$ = nappend1 ( $$ , $11 ); /* (eq p_qual $9) */ d993 1 a993 1 goto yynewstate; d1239 1 @ 1.19 log @target list for x=1 fixed (broken by 1.17 - append fix) @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.18 89/03/20 19:58:10 goh Locked $"; d259 1 a259 1 Create relation_name '(' dom_list ')' d783 1 a783 1 { SkipForwardToFromList(); } a790 1 ResdomNoIsAttrNo = 1; d1086 2 @ 1.18 log @added "merge unsupported elog" @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.14 89/03/20 15:52:03 goh Locked $"; d1241 2 @ 1.17 log @added type checking for append, replace @ text @d447 3 d454 1 @ 1.16 log @append fix @ text @d1222 1 a1222 1 int type_id,type_len; d1225 3 d1231 4 a1236 2 type_id = CInteger(CAR($3)); type_len = tlen(get_id_type(type_id)); d1239 2 a1240 2 type_id, type_len , @ 1.15 log @yet another fix for functions @ text @d35 1 d50 1 d65 1 d700 1 a700 1 { SkipForwardToFromList(); } d702 3 a704 1 opt_star relation_name '(' res_target_list ')' d716 3 a718 2 $$ = nappend1 ( $$ , $7 ); /* (eq p_target $5) */ $$ = nappend1 ( $$ , $9 ); /* (eq p_qual $8 */ d782 1 d786 2 d798 3 a800 3 $$ = nappend1 ( $$ , $8 ); /* (eq p_target $6) */ $$ = nappend1 ( $$ , $10 ); /* (eq p_qual $9) */ d1222 8 a1229 1 int type_id,type_len; d1232 6 a1237 4 $$ = lispCons (lispMakeResdom ( p_last_resno++ , type_id, type_len , $1, 0 , 0 ) , lispCons (CDR($3) , LispNil) ); d1415 1 @ 1.14 log @fixed define function @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.13 89/03/20 11:26:14 goh Exp $"; d378 2 a379 1 { $$ = lispCons ( $1 , lispCons ($3, LispNil)); } d381 1 @ 1.13 log @inheiritance @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.12 89/03/17 20:05:33 goh Exp $"; d188 5 a192 9 /* if(! lispNullp($4)) */ $4 = lispCons($4,LispNil); /* if(! lispNullp($2)) */ $4 = nappend1($4,$2); /* if(! lispNullp($3)) */ $4 = nappend1($4,$3); $$ = nappend1($$,$4); $$ = nappend1($$,$8); $$ = nappend1($$,$9); d333 7 d342 8 a349 1 def_type: Function | Operator | Type ; d357 1 a357 1 { $$ = $4; } d367 2 a368 2 {/*$$ = new_id($1); */} | AexprConst { /* XXX - anyconst in expressions only ? */ } d378 1 a378 5 {/*temp = new_kw("is"); add_sibling($1, $3); $$ = add_child(temp, $1); */} a379 2 {/*temp = new_kw("is"); $$ = add_child(temp, $1);*/} d1294 2 a1295 2 | Keyword { extern char yytext[]; /* defined in scan.l */ d1299 1 a1299 1 Keyword: d1302 1 a1302 1 ; @ 1.12 log @fixed copy @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.11 89/03/14 13:43:52 hirohama Exp $"; d186 1 d188 6 a193 1 if(! lispNullp($4)) a194 4 if(! lispNullp($2)) $$ = nappend1($$,$2); if(! lispNullp($3)) $$ = nappend1($$,$3); d200 5 a204 1 $$ = nappend1 ($$ , $6 ); /* copy_list */ d306 1 a306 1 | Inherits '(' relation_name_list ')' { lispCons ( $1, $3 ) ; } @ 1.11 log @now fixed FETCH completely @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.10 89/03/14 13:19:20 hirohama Locked $"; d186 13 a198 17 if (! lispNullp($3)) $2 = nappend1 (lispCons ($2, LispNil), $3 ) ; else $2 = lispCons ($2 , LispNil ); $4 = lispCons ($4, $2 ); $$ = lispCons ($1 , LispNil) ; $$ = nappend1 ($$ , $4) ; /* to filename */ $8 = lispCons ($8 , lispCons ($9 , LispNil )); $$ = nappend1 ($$ , $8); $$ = nappend1 ($$ , lispCons ( KW(USING) , $10 )); $$ = nappend1 ($$ , $6 ); d228 1 @ 1.10 log @fixes for FETCH @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.9 89/03/13 21:42:48 hirohama Locked $"; d404 3 a406 3 $2 = lispCons ( $2 , LispNil ); $3 = lispCons ( $3 , $2 ); $4 = lispCons ( $4 , $3 ); @ 1.9 log @fix for retrieve into @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.8 89/03/09 21:14:23 hirohama Exp $"; d413 1 a413 1 { $$ = KW(forward); } d420 1 a420 1 { $$ = KW(all) ; } @ 1.8 log @parser now aborts EXECUTE queries @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.7 89/03/07 17:43:28 hirohama Locked $"; d837 1 a837 1 $$=lispCons( KW(NONE) , $2 ); @ 1.7 log @oops, minor fix, type_len, not tlen. - jeff @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.6 89/03/07 16:08:02 goh Exp $"; d750 1 a750 1 elog(NOTICE,"execute does not work in Version 1"); @ 1.6 log @fixes for append and delete @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.5 89/03/07 01:18:48 goh Exp $"; d1204 3 d1208 2 a1209 2 CInteger(CAR($3) ), 0 , $1, 0 , 0 ) , @ 1.5 log @minor fixes to get the range-table to spec @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.3 89/03/02 01:55:17 goh Exp $"; d694 6 a699 1 root = MakeRoot(NumLevels, $1, $5, p_rtable, d702 1 a702 1 $$ = nappend1 ( $$ , $6 ); /* (eq p_target $5) */ d723 6 a728 5 /* root = MakeRoot(NumLevels, $1, $3, p_rtable, p_priority, p_ruleinfo); */ root = MakeRoot(NumLevels,$1,lispInteger ( 1 ) , d732 1 a732 1 $$ = nappend1 ( $$ , $5 ); /* (eq p_target $5) */ d770 3 d774 3 a776 1 root = MakeRoot(NumLevels, $1, $6, p_rtable, d1160 1 a1160 1 if( RangeTablePosn ( CString ($1) ) == 0 ) @ 1.4 log @fix to CREATE -goh @ text @d2 1 a2 1 static char *gram_y ="$Header: /n/postgres/usr2/postgres/postgres/src/parser.NEW/RCS/gram.y,v 1.3 89/03/02 01:55:17 goh Exp $"; d272 2 a273 3 while (temp != LispNil && CDR(temp) != LispNil) { temp = CDR(temp); } d936 1 a936 1 LispValue temp2; d938 1 d950 2 a951 2 temp = lispCons(CAR(temp2),CDR(temp)); p_rtable = nappend1(p_rtable,temp); @ 1.3 log @y @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.2 89/03/02 00:52:52 goh Exp $"; d260 2 d271 6 a276 1 $$ = nappend1 ( $$, $4 ); @ 1.2 log @added many things @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.1 89/02/22 16:12:30 goh Exp $"; d937 2 a938 2 printf("from relname = %s\n",CString(frelname)); fflush(stdout); d963 1 a963 1 printf("now processing where_clause\n"); a1064 4 printf("relname = %s, attrname = %s", CString(CAR($1)), CString(CDR ($1))); fflush(stdout); d1089 1 d1092 1 d1159 7 a1165 3 while (temp != LispNil && CDR(temp) != LispNil) temp = CDR(temp); CDR(temp) = ExpandAll( $1, &p_last_resno); d1172 7 a1178 3 while(temp != LispNil && CDR(temp) != LispNil ) temp = CDR(temp); CDR(temp) = ExpandAll( $3, &p_last_resno); a1185 2 printf ("rte -> type = %d\n", CInteger (CAR ($3))); fflush(stdout); a1189 3 /* printf("done with rte\n"); */ fflush(stdout); d1397 1 a1397 1 printf("name: %s\n"); @ 1.1 log @Initial revision @ text @d2 1 a2 1 static char *gram_y ="$Header: gram.y,v 1.2 89/01/13 17:47:51 goh Locked $"; d188 4 a191 1 $2 = nappend1 (lispCons ($2, LispNil), $3 ) ; d197 1 d201 2 a202 2 $4 = nappend1 ($$ , lispCons ( KW(USING) , $10 )); d800 2 a801 2 $$ = nappend1 ( $$ , $8 ); /* (eq p_target $6) */ $$ = nappend1 ( $$ , $10 ); /* (eq p_qual $9) */ d846 1 a846 1 {/*$$ = add_sibling($1, $2);*/} d933 1 a933 1 while ( ! lispNullp(CDR (temp))) { d937 2 a938 2 /*printf("from relname = %s\n",CString(frelname)); fflush(stdout);*/ d981 1 d1031 2 a1032 1 { $$ = lispCons ( lispString ("AND") , $1 , $3 ) ; } d1034 2 a1035 1 { $$ = lispCons ( lispString ("OR") , $1 , $3 ); } d1039 2 a1040 1 { $$ = lispCons ( lispString ("NOT") , $2 ) ; } d1074 5 a1078 4 /* Type tp = type(CString($1)); char *cp = instr2(tp, CString ($3)); int32 len = tlen(tp); LispValue lcp; d1080 10 a1089 5 if (!tbyvalue(tp)) { if (len >= 0 && len != PSIZE(cp)) { char *pp = palloc(len); bcopy(cp,pp,len); cp = pp; d1091 5 a1095 5 lcp = ppreserve(cp); } else lcp = lispInteger((long) cp); $$ = lispMakeConst ( typeid(tp), len, lcp , 0 ); */ d1153 4 a1156 2 res_target_list ',' res_target_el { INC_LIST ; } | res_target_el { ELEMENT ; p_target = $$;} a1157 1 /* Can't expand "all" because we don't know about range vars yet */ d1159 1 a1159 1 /* XXX expand all */ d1161 4 a1164 4 if( RangeTablePosn ( $1 ) == 0 ) nappend1( p_rtable, MakeRangeTableEntry ( $1 )); $$ = lispCons ( $1 , $3 ); /* $$ = ExpandAll(relname , &p_last_resno);*/ d1167 8 d1187 1 a1187 1 printf("done with rte\n"); @