* GetOverrideSearchPath - fetch current search path definition in form * used by PushOverrideSearchPath. * * The result structure is allocated in the specified memory context * (which might or might not be equal to CurrentMemoryContext); but any * junk created by revalidation calculations will be in CurrentMemoryContext. */
| 3518 | * junk created by revalidation calculations will be in CurrentMemoryContext. |
| 3519 | */ |
| 3520 | OverrideSearchPath * |
| 3521 | GetOverrideSearchPath(MemoryContext context) |
| 3522 | { |
| 3523 | OverrideSearchPath *result; |
| 3524 | List *schemas; |
| 3525 | MemoryContext oldcxt; |
| 3526 | |
| 3527 | recomputeNamespacePath(); |
| 3528 | |
| 3529 | oldcxt = MemoryContextSwitchTo(context); |
| 3530 | |
| 3531 | result = (OverrideSearchPath *) palloc0(sizeof(OverrideSearchPath)); |
| 3532 | schemas = list_copy(activeSearchPath); |
| 3533 | while (schemas && linitial_oid(schemas) != activeCreationNamespace) |
| 3534 | { |
| 3535 | if (linitial_oid(schemas) == myTempNamespace) |
| 3536 | result->addTemp = true; |
| 3537 | else |
| 3538 | { |
| 3539 | Assert(linitial_oid(schemas) == PG_CATALOG_NAMESPACE); |
| 3540 | result->addCatalog = true; |
| 3541 | } |
| 3542 | schemas = list_delete_first(schemas); |
| 3543 | } |
| 3544 | result->schemas = schemas; |
| 3545 | result->generation = activePathGeneration; |
| 3546 | |
| 3547 | MemoryContextSwitchTo(oldcxt); |
| 3548 | |
| 3549 | return result; |
| 3550 | } |
| 3551 | |
| 3552 | /* |
| 3553 | * CopyOverrideSearchPath - copy the specified OverrideSearchPath. |
no test coverage detected