SearchPath returns the effective schema search path for the current session
(ctx *sql.Context)
| 262 | |
| 263 | // SearchPath returns the effective schema search path for the current session |
| 264 | func SearchPath(ctx *sql.Context) ([]string, error) { |
| 265 | path, err := resolve.SearchPath(ctx) |
| 266 | if err != nil { |
| 267 | return nil, err |
| 268 | } |
| 269 | |
| 270 | // pg_catalog is *always* implicitly part of the search path as the first element, unless it's specifically |
| 271 | // included later. This allows users to override built-in names with user-defined names, but they have to |
| 272 | // opt in to that behavior. |
| 273 | hasPgCatalog := false |
| 274 | for _, schema := range path { |
| 275 | if schema == "pg_catalog" { |
| 276 | hasPgCatalog = true |
| 277 | break |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | if !hasPgCatalog { |
| 282 | path = append([]string{"pg_catalog"}, path...) |
| 283 | } |
| 284 | return path, nil |
| 285 | } |
| 286 | |
| 287 | // GetExtensionsCollectionFromContext returns the extensions collection from the given context. Will always return a |
| 288 | // collection if no error is returned. |
no outgoing calls
no test coverage detected