| 441 | AttrNumber attno = 1; |
| 442 | |
| 443 | foreach (lc, original_targetlist) { |
| 444 | TargetEntry* tle = (TargetEntry*)lfirst(lc); |
| 445 | |
| 446 | // Create a new Var node representing this output column |
| 447 | Var* var = makeVar(INDEX_VAR, // varno - special value for scan output |
| 448 | attno, // varattno - column position |
| 449 | exprType((Node*)tle->expr), // vartype |
| 450 | exprTypmod((Node*)tle->expr), // vartypmod |
| 451 | exprCollation((Node*)tle->expr), // varcollid |
| 452 | 0 // varlevelsup |
| 453 | ); |
| 454 | |
| 455 | // Create a new target entry with the Var |
| 456 | TargetEntry* new_tle = |
| 457 | makeTargetEntry((Expr*)var, attno, tle->resname ? pstrdup(tle->resname) : NULL, tle->resjunk); |
| 458 | |
| 459 | new_targetlist = lappend(new_targetlist, new_tle); |
| 460 | attno++; |
| 461 | } |
| 462 | |
| 463 | return new_targetlist; |
| 464 | } |