* apply_map_update * * Insert a new mapping into the given map variable, replacing any existing * mapping for the same relation. * * In some cases the caller knows there must be an existing mapping; pass * add_okay = false to draw an error if not. */
| 323 | * add_okay = false to draw an error if not. |
| 324 | */ |
| 325 | static void |
| 326 | apply_map_update(RelMapFile *map, Oid relationId, Oid fileNode, bool add_okay) |
| 327 | { |
| 328 | int32 i; |
| 329 | |
| 330 | /* Replace any existing mapping */ |
| 331 | for (i = 0; i < map->num_mappings; i++) |
| 332 | { |
| 333 | if (relationId == map->mappings[i].mapoid) |
| 334 | { |
| 335 | map->mappings[i].mapfilenode = fileNode; |
| 336 | return; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | /* Nope, need to add a new mapping */ |
| 341 | if (!add_okay) |
| 342 | elog(ERROR, "attempt to apply a mapping to unmapped relation %u", |
| 343 | relationId); |
| 344 | if (map->num_mappings >= MAX_MAPPINGS) |
| 345 | elog(ERROR, "ran out of space in relation map"); |
| 346 | map->mappings[map->num_mappings].mapoid = relationId; |
| 347 | map->mappings[map->num_mappings].mapfilenode = fileNode; |
| 348 | map->num_mappings++; |
| 349 | } |
| 350 | |
| 351 | /* |
| 352 | * merge_map_updates |
no outgoing calls
no test coverage detected