Skip to content

Commit c7b4047

Browse files
committed
Improve print_expr() a little. It's still not very bright though.
1 parent e211481 commit c7b4047

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

src/backend/nodes/print.c

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.59 2003/01/15 19:35:39 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.60 2003/01/22 19:26:35 tgl Exp $
1212
*
1313
* HISTORY
1414
* AUTHOR DATE MAJOR EVENT
@@ -362,24 +362,43 @@ print_expr(Node *expr, List *rtable)
362362
printf("%s", outputstr);
363363
pfree(outputstr);
364364
}
365-
else if (IsA(expr, Expr))
365+
else if (IsA(expr, OpExpr))
366366
{
367-
Expr *e = (Expr *) expr;
367+
OpExpr *e = (OpExpr *) expr;
368+
char *opname;
368369

369-
if (is_opclause(expr))
370+
opname = get_opname(e->opno);
371+
if (length(e->args) > 1)
370372
{
371-
char *opname;
372-
373-
print_expr(get_leftop(e), rtable);
374-
opname = get_opname(((OpExpr *) e)->opno);
373+
print_expr(get_leftop((Expr *) e), rtable);
375374
printf(" %s ", ((opname != NULL) ? opname : "(invalid operator)"));
376-
print_expr(get_rightop(e), rtable);
375+
print_expr(get_rightop((Expr *) e), rtable);
377376
}
378377
else
379-
printf("an expr");
378+
{
379+
/* we print prefix and postfix ops the same... */
380+
printf("%s ", ((opname != NULL) ? opname : "(invalid operator)"));
381+
print_expr(get_leftop((Expr *) e), rtable);
382+
}
383+
}
384+
else if (IsA(expr, FuncExpr))
385+
{
386+
FuncExpr *e = (FuncExpr *) expr;
387+
char *funcname;
388+
List *l;
389+
390+
funcname = get_func_name(e->funcid);
391+
printf("%s(", ((funcname != NULL) ? funcname : "(invalid function)"));
392+
foreach(l, e->args)
393+
{
394+
print_expr(lfirst(l), rtable);
395+
if (lnext(l))
396+
printf(",");
397+
}
398+
printf(")");
380399
}
381400
else
382-
printf("not an expr");
401+
printf("unknown expr");
383402
}
384403

385404
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy