Skip to content

Backup restoration failing due to index on h3_lat_lng_to_cell #168

@ericsvg

Description

@ericsvg

Hello,

Creating a dump using pg_dump and later restoring it fails due to the following error:

ERROR:  function h3_lat_lng_to_cell(point, integer) does not exist
LINE 1:  SELECT h3_lat_lng_to_cell($1::point, $2); 
                ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
QUERY:   SELECT h3_lat_lng_to_cell($1::point, $2); 
CONTEXT:  SQL function "h3_lat_lng_to_cell" during inlining

I believe this is due to the conjunction of two things:

  • pg_dump setting search_path to an empty string in the dump it creates
[...]
SELECT pg_catalog.set_config('search_path', '', false);
[...]
  • The definition of h3_lat_lng_to_cell not explicitly using the namespace of the point type (public)
CREATE OR REPLACE FUNCTION h3_lat_lng_to_cell(geometry, resolution integer) RETURNS h3index
    AS $$ SELECT h3_lat_lng_to_cell($1::point, $2); $$ IMMUTABLE STRICT PARALLEL SAFE LANGUAGE SQL;
COMMENT ON FUNCTION
    h3_lat_lng_to_cell(geometry, resolution integer)
IS 'Indexes the location at the specified resolution.';

This is not an issue when one can modify the created dump (adding SET search_path TO "$user", public, topology; fixes it), however this causes issues in RDS for a database upgrade.

Not quite sure how to confirm that changing to $1::public.point would fix the problem.

If that helps, here's a the full SQL file created with pg_dump for a reproducible example.

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

CREATE TABLE public.foo (
    bar public.geometry(Point,4326) NOT NULL
);


CREATE INDEX foo_h3_lat_lng_to_cell_idx ON public.foo USING btree (public.h3_lat_lng_to_cell(bar, 15));

Let me know if you need anything else!

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions