* Fill in the IndexAmRoutine for an index relation. * * relation's rd_amhandler and rd_indexcxt must be valid already. */
| 1445 | * relation's rd_amhandler and rd_indexcxt must be valid already. |
| 1446 | */ |
| 1447 | static void |
| 1448 | InitIndexAmRoutine(Relation relation) |
| 1449 | { |
| 1450 | IndexAmRoutine *cached, |
| 1451 | *tmp; |
| 1452 | |
| 1453 | /* |
| 1454 | * Call the amhandler in current, short-lived memory context, just in case |
| 1455 | * it leaks anything (it probably won't, but let's be paranoid). |
| 1456 | */ |
| 1457 | tmp = GetIndexAmRoutine(relation->rd_amhandler); |
| 1458 | |
| 1459 | /* OK, now transfer the data into relation's rd_indexcxt. */ |
| 1460 | cached = (IndexAmRoutine *) MemoryContextAlloc(relation->rd_indexcxt, |
| 1461 | sizeof(IndexAmRoutine)); |
| 1462 | memcpy(cached, tmp, sizeof(IndexAmRoutine)); |
| 1463 | relation->rd_indam = cached; |
| 1464 | |
| 1465 | pfree(tmp); |
| 1466 | } |
| 1467 | |
| 1468 | /* |
| 1469 | * Initialize index-access-method support data for an index relation |
no test coverage detected