SearchPath

internal class SearchPath(val setting: String, val sessionUser: String?)

A session's search_path, read from what the server reports, and the order the server looks a type name up in.

The report is the setting's text, which is not the path the server searches. SET normalizes what it is given before storing it, but set_config and a startup parameter store the text as written, so Gallia arrives as Gallia and means gallia. The setting also names schemas by alias - $user, pg_temp - and leaves out the ones searched without being listed. Both halves are worked out here the way namespace.c works them out.

What the server knows and does not report, this cannot follow:

  • $user is the current role, and SET ROLE moves it without a ParameterStatus (role is not reported in PostgreSQL 18). It is taken from session_authorization, which SET SESSION AUTHORIZATION does report.

  • A listed schema the current role has no USAGE on is skipped by the server and kept here.

  • The session's temporary schema is a pg_temp_N created with its first temporary object, and reported nowhere. The server searches it ahead of everything else for type names, pg_catalog included, or where pg_temp stands in the setting; it is left out here either way.

Constructors

Link copied to clipboard
constructor(setting: String, sessionUser: String?)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The setting's entries, split as the server splits them: an unquoted name folded to lower case, a quoted one unquoted, every name cut to MAX_NAME_BYTES. $user and pg_temp stay as they are.

Link copied to clipboard

the reported session_authorization, which $user stands for, or null where none was.

Link copied to clipboard

the reported search_path, as it arrived.

Link copied to clipboard

The schemas an unqualified type name is looked up in, first match winning: entries with $user as sessionUser, or without it where there is none, without pg_temp, and with pg_catalog ahead of them unless they list it.

Functions

Link copied to clipboard
fun isFor(setting: String, sessionUser: String?): Boolean

Whether this was read from these two reports, and so still holds while they are what the server says.