Skip to content

Impossible to create indices on expressions involving some h3 functions in PosrgreSQL 17 #165

@spaghettiguru

Description

@spaghettiguru

First of all, thanks for maintaining this, to everyone involved!

The issue

Given the table defined like this:

CREATE TABLE my_table (
    h3cell h3index
)

An attempt to create the following index on it CREATE INDEX ON my_table USING GIST (h3_cell_to_geometry(h3cell)) fails in Postgres >= 17 .

This seems to happen because of the changes in Postgres 17 around index creation which make accessing non-standard schema-unqualified object references during index creation to fail, since PostgreSQL now temporarily modifies the search_path when running some operations and these objects cannot be found.
Here is the quote from the PostgreSQL 17 release notes:

Change functions to use a safe search_path during maintenance operations

This prevents maintenance operations (ANALYZE, CLUSTER, CREATE INDEX, CREATE MATERIALIZED VIEW, REFRESH MATERIALIZED VIEW, REINDEX, or VACUUM) from performing unsafe access. Functions used by expression indexes and materialized views that need to reference non-default schemas must specify a search path during function creation.

They also updated the docs for CREATE INDEX command to contain this:

While CREATE INDEX is running, the search_path is temporarily changed to pg_catalog, pg_temp.

So I guess the solution would be to qualify the references to extension objects inside h3 functions with the right schema - where needed.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions