Skip to content

basalt / search-postgres/src / PostgresSearchFunctionOptions

Interface: PostgresSearchFunctionOptions ​

Defined in: search-postgres/src/index.ts:24

Routes full-text queries through a SECURITY DEFINER function instead of querying the table directly — the fix for the row-level-security plan trap.

On a search table protected by Postgres RLS, tsv @@ to_tsquery(…) can never become an index condition for a role the policy applies to: @@ is not LEAKPROOF, so it must be evaluated after the policy, and the GIN index silently drops out of the plan (sequential scan over every tenant's rows). Generate the function with rlsSearchFunctionSql() from @basaltkit/prisma and name it here; the driver then calls it, and the index is used again.

The function takes no tenant parameter: it reads the tenant from the same current_setting(…) the policy reads, so it can only ever return rows of the tenant already set on the connection. The driver still checks every returned row against the query's tenantId and refuses a mismatch.

Properties ​

name ​

> name: string

Defined in: search-postgres/src/index.ts:26

Unqualified name of the function (rlsSearchFunctionSql's name).


schema? ​

> optional schema?: string

Defined in: search-postgres/src/index.ts:28

Schema it lives in. Default public.

Released under the MIT License.