diff --git a/packages/function-resolution/__tests__/request-lane-reads.test.ts b/packages/function-resolution/__tests__/request-lane-reads.test.ts index 9fedd5a5..501476a5 100644 --- a/packages/function-resolution/__tests__/request-lane-reads.test.ts +++ b/packages/function-resolution/__tests__/request-lane-reads.test.ts @@ -218,9 +218,9 @@ describe('request-lane resolution reads', () => { it('lists every database-scope plane in resolution order for its grantee', async () => { const planes = await pg.any(`SELECT * FROM function_resolution.routing_planes()`); expect(planes).toEqual([ - { database_id: PLATFORM_DB, schema_name: 'platform_storage_public', resolver_function_name: 'resolve_route' }, - { database_id: TENANT_DB, schema_name: 'tenant_storage_public', resolver_function_name: 'resolve_route' }, - { database_id: OTHER_DB, schema_name: 'other_storage_public', resolver_function_name: 'resolve_route' } + { database_id: PLATFORM_DB, schema_name: 'platform_storage_public', resolver_schema_name: 'platform_storage_public', resolver_function_name: 'resolve_route' }, + { database_id: TENANT_DB, schema_name: 'tenant_storage_public', resolver_schema_name: 'tenant_storage_public', resolver_function_name: 'resolve_route' }, + { database_id: OTHER_DB, schema_name: 'other_storage_public', resolver_schema_name: 'other_storage_public', resolver_function_name: 'resolve_route' } ]); }); }); diff --git a/packages/function-resolution/deploy/schemas/function_resolution/procedures/routing_planes.sql b/packages/function-resolution/deploy/schemas/function_resolution/procedures/routing_planes.sql index b2052f12..6e138d3c 100644 --- a/packages/function-resolution/deploy/schemas/function_resolution/procedures/routing_planes.sql +++ b/packages/function-resolution/deploy/schemas/function_resolution/procedures/routing_planes.sql @@ -12,17 +12,24 @@ BEGIN; -- -- It enumerates every tenant database, so it is granted to no request role: -- only the platform login (granted at provision) calls it, on its own --- connection with no role switch. A plane whose route_module names no schema --- or no resolver is returned as-is so the caller fails loudly on it. +-- connection with no role switch. schema_name is the plane's public schema +-- (its tables); resolver_schema_name is the schema its resolver is generated +-- into, so callers qualify the resolver from it rather than assuming. The +-- readers are still generated into the public schema, so for now both columns +-- carry the same value; resolver_schema_name changes to the plane's private +-- schema when the readers move there. A plane whose route_module names no +-- schema or no resolver is returned as-is so the caller fails loudly on it. CREATE FUNCTION function_resolution.routing_planes() RETURNS TABLE ( database_id uuid, schema_name text, + resolver_schema_name text, resolver_function_name text ) AS $$ SELECT rm.database_id, s.schema_name::text, + s.schema_name::text, rm.resolver_function_name FROM metaschema_modules_public.route_module AS rm LEFT JOIN metaschema_public.schema AS s ON s.id = rm.schema_id diff --git a/packages/function-resolution/sql/pgpm-function-resolution--0.47.6.bundle.tar.gz b/packages/function-resolution/sql/pgpm-function-resolution--0.47.6.bundle.tar.gz index 7fe7fba0..380d59a4 100644 Binary files a/packages/function-resolution/sql/pgpm-function-resolution--0.47.6.bundle.tar.gz and b/packages/function-resolution/sql/pgpm-function-resolution--0.47.6.bundle.tar.gz differ diff --git a/packages/function-resolution/sql/pgpm-function-resolution--0.47.6.sql b/packages/function-resolution/sql/pgpm-function-resolution--0.47.6.sql index a3926253..025d94ac 100644 --- a/packages/function-resolution/sql/pgpm-function-resolution--0.47.6.sql +++ b/packages/function-resolution/sql/pgpm-function-resolution--0.47.6.sql @@ -2408,11 +2408,13 @@ $EOFCODE$ LANGUAGE plpgsql VOLATILE; CREATE FUNCTION function_resolution.routing_planes() RETURNS TABLE ( database_id uuid, schema_name text, + resolver_schema_name text, resolver_function_name text ) AS $EOFCODE$ SELECT rm.database_id, s.schema_name::text, + s.schema_name::text, rm.resolver_function_name FROM metaschema_modules_public.route_module AS rm LEFT JOIN metaschema_public.schema AS s ON s.id = rm.schema_id