For attrMapExpr below. * * Mutate Var nodes in an expression using the given attribute map. * Insist the Var nodes have varno == 1 and the that the mapping * yields a live attribute number (non-zero). */
| 4177 | * yields a live attribute number (non-zero). |
| 4178 | */ |
| 4179 | static Node *apply_attrmap_mutator(Node *node, TupleConversionMap *map) |
| 4180 | { |
| 4181 | if ( node == NULL ) |
| 4182 | return NULL; |
| 4183 | |
| 4184 | if (IsA(node, Var) ) |
| 4185 | { |
| 4186 | Var *var = (Var *) node; |
| 4187 | AttrNumber anum; |
| 4188 | |
| 4189 | Assert(var->varno == 1); /* in CHECK constraints */ |
| 4190 | anum = attrMap(map, var->varattno); |
| 4191 | |
| 4192 | if (anum == 0) |
| 4193 | { |
| 4194 | /* Should never happen, but best caught early. */ |
| 4195 | elog(ERROR, "attribute map discrepancy"); |
| 4196 | } |
| 4197 | else if (anum != var->varattno) |
| 4198 | { |
| 4199 | var = copyObject(var); |
| 4200 | var->varattno = anum; |
| 4201 | } |
| 4202 | return (Node *) var; |
| 4203 | } |
| 4204 | return expression_tree_mutator(node, apply_attrmap_mutator, (void *) map); |
| 4205 | } |
| 4206 | |
| 4207 | /* Apply attrMap over the Var nodes in an expression. */ |
| 4208 | Node * |
no test coverage detected