* exprType - * returns the Oid of the type of the expression's result. */
| 40 | * returns the Oid of the type of the expression's result. |
| 41 | */ |
| 42 | Oid |
| 43 | exprType(const Node *expr) |
| 44 | { |
| 45 | Oid type; |
| 46 | |
| 47 | if (!expr) |
| 48 | return InvalidOid; |
| 49 | |
| 50 | switch (nodeTag(expr)) |
| 51 | { |
| 52 | case T_Var: |
| 53 | type = ((const Var *) expr)->vartype; |
| 54 | break; |
| 55 | case T_Const: |
| 56 | type = ((const Const *) expr)->consttype; |
| 57 | break; |
| 58 | case T_Param: |
| 59 | type = ((const Param *) expr)->paramtype; |
| 60 | break; |
| 61 | case T_Aggref: |
| 62 | type = ((const Aggref *) expr)->aggtype; |
| 63 | break; |
| 64 | case T_GroupingFunc: |
| 65 | type = INT4OID; |
| 66 | break; |
| 67 | case T_GroupId: |
| 68 | type = INT4OID; |
| 69 | break; |
| 70 | case T_GroupingSetId: |
| 71 | type = INT4OID; |
| 72 | break; |
| 73 | case T_WindowFunc: |
| 74 | type = ((const WindowFunc *) expr)->wintype; |
| 75 | break; |
| 76 | case T_SubscriptingRef: |
| 77 | type = ((const SubscriptingRef *) expr)->refrestype; |
| 78 | break; |
| 79 | case T_FuncExpr: |
| 80 | type = ((const FuncExpr *) expr)->funcresulttype; |
| 81 | break; |
| 82 | case T_NamedArgExpr: |
| 83 | type = exprType((Node *) ((const NamedArgExpr *) expr)->arg); |
| 84 | break; |
| 85 | case T_OpExpr: |
| 86 | type = ((const OpExpr *) expr)->opresulttype; |
| 87 | break; |
| 88 | case T_DistinctExpr: |
| 89 | type = ((const DistinctExpr *) expr)->opresulttype; |
| 90 | break; |
| 91 | case T_NullIfExpr: |
| 92 | type = ((const NullIfExpr *) expr)->opresulttype; |
| 93 | break; |
| 94 | case T_ScalarArrayOpExpr: |
| 95 | type = BOOLOID; |
| 96 | break; |
| 97 | case T_BoolExpr: |
| 98 | type = BOOLOID; |
| 99 | break; |