Sets the effective tenancy of a multi-tenant database connection for a super-tenant user. A super tenant has no real tenancy of its own, but can act as if it is a particular regular tenant without the user having to authenticate a new connection identity that has that particular tenancy. Therefore, the effective tenancy is the acting regular tenancy of a super tenant.
SET-EFFECTIVE-TENANT ( tenant-expression , database-name )An integer or character string expression. If tenant-expression evaluates to an integer, the value must be a valid tenant ID for a regular or default tenant. If tenant-expression evaluates to a character string, the value must be a valid tenant name for a regular or default tenant. Otherwise, the statement raises ERROR.
If a regular-tenant user executes this function, the tenant identified by tenant-expression must match the user’s tenancy; otherwise, the function raises an error. If a super-tenant user executes this function, and tenant-expression is not a valid regular tenant (not a super tenant), the function raises an error.
All super-tenant users login with access to shared data and data owned by the effective default tenant, with access conditioned on the user’s table and field permission settings. When a super-tenant user executes SET-EFFECTIVE-TENANT, they have access to shared data and data owned by the new effective tenant, with access, again, conditioned by the user’s same table and field permission settings. This super-tenant access can include data for multiple tenants, without changing effective tenancy, by using the TENANT-WHERE option of the record phrase. (The TENANT-WHERE option, itself, does not change the effective tenancy.)
The scope of SET-EFFECTIVE-TENANT ends when a new identity is set for the database connection using the SET-DB-CLIENT function, the SECURITY-POLICY:SET-CLIENT( ) method, or the SETUSERID function, at which point the effective tenancy changes back to the default tenant for any super tenant user identity or to the real tenant of a regular tenant user identity (including the default tenant). Unlike setting the effective tenant, setting a new connection identity also clears buffers and cursors of any prior tenant data.
The AVM looks up tenant-expression in the _Tenant table with a share lock. The AVM waits 60 seconds to get the share lock, and if it fails to get the share lock in that amount of time, the AVM raises an error. The AVM releases the share lock immediately after successfully retrieving the tenant information. This share lock is released even if the function is called within a transaction.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |