1010 *
1111 *
1212 * IDENTIFICATION
13- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.63 1997/11/07 07:02:07 thomas Exp $
13+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.64 1997/11/10 15:22:36 thomas Exp $
1414 *
1515 * HISTORY
1616 * AUTHORDATEMAJOR EVENT
@@ -456,9 +456,6 @@ alter_clause: ADD opt_column columnDef
456456
457457if (length($3) != 1)
458458elog(WARN,"ALTER TABLE/ADD() allows one column only",NULL);
459- #ifdef PARSEDEBUG
460- printf( "list has %d elements\n", length($3));
461- #endif
462459$$ = lp;
463460}
464461| DROP opt_column ColId
@@ -743,15 +740,9 @@ ConstraintElem:
743740ConstraintDef:CHECK constraint_elem
744741{
745742ConstraintDef *constr = palloc (sizeof(ConstraintDef));
746- #ifdef PARSEDEBUG
747- printf("in ConstraintDef\n");
748- #endif
749743constr->type = CONSTR_CHECK;
750744constr->name = NULL;
751745constr->def = FlattenStringList($2);
752- #ifdef PARSEDEBUG
753- printf("ConstraintDef: string is %s\n", (char *) constr->def);
754- #endif
755746$$ = constr;
756747}
757748| UNIQUE '(' columnList ')'
@@ -768,9 +759,6 @@ constraint_elem: AexprConst
768759{$$ = lcons( makeString("NULL"), NIL); }
769760| ColId
770761{
771- #ifdef PARSEDEBUG
772- printf( "ColId is %s\n", $1);
773- #endif
774762$$ = lcons( makeString(fmtId($1)), NIL);
775763}
776764| '-' constraint_elem %prec UMINUS
@@ -1037,21 +1025,12 @@ def_rest: def_name definition
10371025{
10381026$$ = makeNode(DefineStmt);
10391027$$->defname = $1;
1040- #ifdef PARSEDEBUG
1041- printf("def_rest: defname is %s\n", $1);
1042- #endif
10431028$$->definition = $2;
10441029}
10451030;
10461031
10471032def_type: OPERATOR{ $$ = OPERATOR; }
1048- | Type
1049- {
1050- #ifdef PARSEDEBUG
1051- printf("def_type: decoding TYPE_P\n");
1052- #endif
1053- $$ = TYPE_P;
1054- }
1033+ | Type{ $$ = TYPE_P; }
10551034| AGGREGATE{ $$ = AGGREGATE; }
10561035;
10571036
@@ -1071,29 +1050,18 @@ def_list: def_elem{ $$ = lcons($1, NIL); }
10711050
10721051def_elem: def_name '=' def_arg
10731052{
1074- #ifdef PARSEDEBUG
1075- printf("def_elem: decoding %s =\n", $1);
1076- pprint($3);
1077- #endif
10781053$$ = makeNode(DefElem);
10791054$$->defname = $1;
10801055$$->arg = (Node *)$3;
10811056}
10821057| def_name
10831058{
1084- #ifdef PARSEDEBUG
1085- printf("def_elem: decoding %s\n", $1);
1086- #endif
10871059$$ = makeNode(DefElem);
10881060$$->defname = $1;
10891061$$->arg = (Node *)NULL;
10901062}
10911063| DEFAULT '=' def_arg
10921064{
1093- #ifdef PARSEDEBUG
1094- printf("def_elem: decoding DEFAULT =\n");
1095- pprint($3);
1096- #endif
10971065$$ = makeNode(DefElem);
10981066$$->defname = "default";
10991067$$->arg = (Node *)$3;
@@ -2406,14 +2374,14 @@ time_range: '[' opt_range_start ',' opt_range_end ']'
24062374$$ = makeNode(TimeRange);
24072375$$->startDate = $2;
24082376$$->endDate = $4;
2409- elog (WARN, "parser: TimeRange isnot supported ");
2377+ elog (WARN, "time travel isno longer available ");
24102378}
24112379| '[' date ']'
24122380{
24132381$$ = makeNode(TimeRange);
24142382$$->startDate = $2;
24152383$$->endDate = NULL;
2416- elog (WARN, "parser: TimeRange isnot supported ");
2384+ elog (WARN, "time travel isno longer available ");
24172385}
24182386;
24192387
@@ -3057,9 +3025,6 @@ extract_list: datetime FROM a_expr
30573025A_Const *n = makeNode(A_Const);
30583026n->val.type = T_String;
30593027n->val.val.str = $1;
3060- #ifdef PARSEDEBUG
3061- printf( "string is %s\n", $1);
3062- #endif
30633028$$ = lappend(lcons((Node *)n,NIL), $3);
30643029}
30653030| /* EMPTY */
@@ -3581,6 +3546,7 @@ static Node *makeA_Expr(int oper, char *opname, Node *lexpr, Node *rexpr)
35813546return (Node *)a;
35823547}
35833548
3549+
35843550static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
35853551{
35863552Node *result = NULL;
@@ -3748,7 +3714,7 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
37483714if (result == NULL)
37493715result = makeA_Expr(OP, opname, lexpr, rexpr);
37503716return result;
3751- }
3717+ } /* makeIndexable() */
37523718
37533719
37543720/* xlateSqlType()
@@ -3774,6 +3740,7 @@ xlateSqlType(char *name)
37743740return name;
37753741} /* xlateSqlName() */
37763742
3743+
37773744void parser_init(Oid *typev, int nargs)
37783745{
37793746QueryIsRule = FALSE;
@@ -3783,6 +3750,7 @@ void parser_init(Oid *typev, int nargs)
37833750param_type_init(typev, nargs);
37843751}
37853752
3753+
37863754/* FlattenStringList()
37873755 * Traverse list of string nodes and convert to a single string.
37883756 * Used for reconstructing string form of complex expressions.
@@ -3799,17 +3767,11 @@ FlattenStringList(List *list)
37993767int nlist, len = 0;
38003768
38013769nlist = length(list);
3802- #ifdef PARSEDEBUG
3803- printf( "list has %d elements\n", nlist);
3804- #endif
38053770l = list;
38063771while(l != NIL) {
38073772v = (Value *)lfirst(l);
38083773sp = v->val.str;
38093774l = lnext(l);
3810- #ifdef PARSEDEBUG
3811- printf( "sp is x%8p; length of %s is %d\n", sp, sp, strlen(sp));
3812- #endif
38133775len += strlen(sp);
38143776};
38153777len += nlist;
@@ -3822,9 +3784,6 @@ printf( "sp is x%8p; length of %s is %d\n", sp, sp, strlen(sp));
38223784v = (Value *)lfirst(l);
38233785sp = v->val.str;
38243786l = lnext(l);
3825- #ifdef PARSEDEBUG
3826- printf( "length of %s is %d\n", sp, strlen(sp));
3827- #endif
38283787strcat(s,sp);
38293788if (l != NIL) strcat(s," ");
38303789};
@@ -3837,46 +3796,33 @@ printf( "flattened string is \"%s\"\n", s);
38373796return(s);
38383797} /* FlattenStringList() */
38393798
3799+
38403800/* makeConstantList()
38413801 * Convert constant value node into string node.
38423802 */
38433803static List *
38443804makeConstantList( A_Const *n)
38453805{
38463806char *defval = NULL;
3847- #ifdef PARSEDEBUG
3848- printf( "in AexprConst\n");
3849- #endif
38503807if (nodeTag(n) != T_A_Const) {
38513808elog(WARN,"Cannot handle non-constant parameter",NULL);
38523809
38533810} else if (n->val.type == T_Float) {
3854- #ifdef PARSEDEBUG
3855- printf( "AexprConst float is %f\n", n->val.val.dval);
3856- #endif
38573811defval = (char*) palloc(20+1);
38583812sprintf( defval, "%g", n->val.val.dval);
38593813
38603814} else if (n->val.type == T_Integer) {
3861- #ifdef PARSEDEBUG
3862- printf( "AexprConst integer is %ld\n", n->val.val.ival);
3863- #endif
38643815defval = (char*) palloc(20+1);
38653816sprintf( defval, "%ld", n->val.val.ival);
38663817
38673818} else if (n->val.type == T_String) {
3868-
3869- #ifdef PARSEDEBUG
3870- printf( "AexprConst string is \"%s\"\n", n->val.val.str);
3871- #endif
3872-
38733819defval = (char*) palloc(strlen( ((A_Const *) n)->val.val.str) + 3);
38743820strcpy( defval, "'");
38753821strcat( defval, ((A_Const *) n)->val.val.str);
38763822strcat( defval, "'");
38773823
38783824} else {
3879- elog(WARN,"Internal error: cannot encode node",NULL);
3825+ elog(WARN,"Internal error in makeConstantList() : cannot encode node",NULL);
38803826};
38813827
38823828#ifdef PARSEDEBUG
@@ -3886,6 +3832,7 @@ printf( "AexprConst argument is \"%s\"\n", defval);
38863832return( lcons( makeString(defval), NIL));
38873833} /* makeConstantList() */
38883834
3835+
38893836/* fmtId()
38903837 * Check input string for non-lowercase/non-numeric characters.
38913838 * Returns either input string or input surrounded by double quotes.