| 265 | } |
| 266 | |
| 267 | static TupleTableSlot * |
| 268 | ExecFilterJunkInternal(JunkFilter *junkfilter, TupleTableSlot *slot) |
| 269 | { |
| 270 | TupleTableSlot *resultSlot; |
| 271 | AttrNumber *cleanMap; |
| 272 | TupleDesc cleanTupType; |
| 273 | int cleanLength; |
| 274 | int i; |
| 275 | Datum *values; |
| 276 | bool *isnull; |
| 277 | Datum *old_values; |
| 278 | bool *old_isnull; |
| 279 | |
| 280 | /* |
| 281 | * Extract all the values of the old tuple. |
| 282 | */ |
| 283 | slot_getallattrs(slot); |
| 284 | old_values = slot->tts_values; |
| 285 | old_isnull = slot->tts_isnull; |
| 286 | |
| 287 | /* |
| 288 | * get info from the junk filter |
| 289 | */ |
| 290 | cleanTupType = junkfilter->jf_cleanTupType; |
| 291 | cleanLength = cleanTupType->natts; |
| 292 | cleanMap = junkfilter->jf_cleanMap; |
| 293 | resultSlot = junkfilter->jf_resultSlot; |
| 294 | |
| 295 | /* |
| 296 | * Prepare to build a virtual result tuple. |
| 297 | */ |
| 298 | ExecClearTuple(resultSlot); |
| 299 | values = resultSlot->tts_values; |
| 300 | isnull = resultSlot->tts_isnull; |
| 301 | |
| 302 | /* |
| 303 | * Transpose data into proper fields of the new tuple. |
| 304 | */ |
| 305 | for (i = 0; i < cleanLength; i++) |
| 306 | { |
| 307 | int j = cleanMap[i]; |
| 308 | |
| 309 | if (j == 0) |
| 310 | { |
| 311 | values[i] = (Datum) 0; |
| 312 | isnull[i] = true; |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | values[i] = old_values[j - 1]; |
| 317 | isnull[i] = old_isnull[j - 1]; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | * And return the virtual tuple. |
| 323 | */ |
| 324 | return ExecStoreVirtualTuple(resultSlot); |
no test coverage detected