|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.123 2002/07/18 17:14:19 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.124 2002/08/04 06:46:12 thomas Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -282,6 +282,41 @@ transformExpr(ParseState *pstate, Node *expr)
|
282 | 282 | rexpr);
|
283 | 283 | ((Expr *)result)->opType = DISTINCT_EXPR;
|
284 | 284 | }
|
| 285 | + break; |
| 286 | + case OF: |
| 287 | + { |
| 288 | + List *telem; |
| 289 | + A_Const *n; |
| 290 | + Oid ltype, rtype; |
| 291 | + bool matched = FALSE; |
| 292 | + |
| 293 | + /* Checking an expression for match to type. |
| 294 | + * Will result in a boolean constant node. |
| 295 | + */ |
| 296 | + Node *lexpr = transformExpr(pstate, |
| 297 | + a->lexpr); |
| 298 | + ltype = exprType(lexpr); |
| 299 | + foreach(telem, (List *) a->rexpr) |
| 300 | + { |
| 301 | + rtype = LookupTypeName(lfirst(telem)); |
| 302 | + matched = (rtype == ltype); |
| 303 | + if (matched) break; |
| 304 | + } |
| 305 | + |
| 306 | + /* Expect two forms: equals or not equals. |
| 307 | + * Flip the sense of the result for not equals. |
| 308 | + */ |
| 309 | + if (strcmp(strVal(lfirst(a->name)), "!=") == 0) |
| 310 | + matched = (! matched); |
| 311 | + |
| 312 | + n = makeNode(A_Const); |
| 313 | + n->val.type = T_String; |
| 314 | + n->val.val.str = (matched? "t": "f"); |
| 315 | + n->typename = SystemTypeName("bool"); |
| 316 | + |
| 317 | + result = transformExpr(pstate, (Node *) n); |
| 318 | + } |
| 319 | + break; |
285 | 320 | }
|
286 | 321 | break;
|
287 | 322 | }
|
@@ -589,14 +624,14 @@ transformExpr(ParseState *pstate, Node *expr)
|
589 | 624 | break;
|
590 | 625 | }
|
591 | 626 |
|
592 |
| - /* |
593 |
| - * Quietly accept node types that may be presented when we are |
594 |
| - * called on an already-transformed tree. |
595 |
| - * |
596 |
| - * Do any other node types need to be accepted? For now we are |
597 |
| - * taking a conservative approach, and only accepting node |
598 |
| - * types that are demonstrably necessary to accept. |
599 |
| - */ |
| 627 | + /********************************************* |
| 628 | + * Quietly accept node types that may be presented when we are |
| 629 | + * called on an already-transformed tree. |
| 630 | + * |
| 631 | + * Do any other node types need to be accepted? For now we are |
| 632 | + * taking a conservative approach, and only accepting node |
| 633 | + * types that are demonstrably necessary to accept. |
| 634 | + *********************************************/ |
600 | 635 | case T_Expr:
|
601 | 636 | case T_Var:
|
602 | 637 | case T_Const:
|
|
0 commit comments