Opened 5 years ago
Closed 5 years ago
#4546 closed defect (fixed)
ST_ConcaveHull fails to execute through FDW
Reported by: | Algunenano | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.4.9 |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description
Source server: PG12 + Postgis 3 Remove server: Tested both PG12 with Postgis 3 and PG11 with Postgis 2.5, same result.
The FDW server is created with extensions: 'postgis'
so the function can be shipped to the remote, e.g.:
CREATE server remote_server foreign data wrapper postgres_fdw options (host '127.0.0.1', port '5432', dbname 'cartodb_dev_user_3e4a6fc6-4137-4c59-bc63-066f80efb90e_db', extensions 'postgis', fetch_size '10000', use_remote_estimate 'true');
Example plan:
explain (verbose) Select ST_ConcaveHull(ST_Collect(the_geom), 0.7, true) from remote_local.populated; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- ------- Foreign Scan (cost=594.53..594.83 rows=1 width=32) Output: (st_concavehull(st_collect(the_geom), '0.7'::double precision, true)) Relations: Aggregate on (remote_local.populated) Remote SQL: SELECT public.st_concavehull(public.st_collect(the_geom), 0.7::double precision, true) FROM public.populated (4 rows)
Error:
ERROR: type "geometry" does not exist CONTEXT: compilation of PL/pgSQL function "_st_concavehull" near line 3 PL/pgSQL function public.st_concavehull(public.geometry,double precision,boolean) line 152 at assignment SQL statement "SELECT public.ST_Buffer(public.ST_ConcaveHull(var_geoms[1],least(param_pctconvex + param_pctconvex/var_div),true),var_buf, 'quad_segs=2')" PL/pgSQL function public.st_concavehull(public.geometry,double precision,boolean) line 114 at assignment SQL statement "SELECT public.ST_Buffer(public.ST_ConcaveHull(var_geoms[1],least(param_pctconvex + param_pctconvex/var_div),true),var_buf, 'quad_segs=2')" PL/pgSQL function public.st_concavehull(public.geometry,double precision,boolean) line 114 at assignment PL/pgSQL function public.st_concavehull(public.geometry,double precision,boolean) line 114 at assignment remote SQL command: SELECT public.st_concavehull(public.st_collect(the_geom), 0.7::double precision, true) FROM public.all_month
This is happening because postgres_fdw removes all schemas from the search_path, and although we qualify function calls using @extschema@, we don't do it for types.
If I then qualified all geometry usages, the following error arises:
explain (analyze, verbose) Select ST_ConcaveHull(ST_Collect(the_geom), 0.7, true) from remote_local.all_month; ERROR: relation "geometry_dump" does not exist CONTEXT: SQL statement "SELECT public.ST_MakeLine(geom) FROM public.ST_Dump(cavering) As foo" PL/pgSQL function public._st_concavehull(public.geometry) line 49 at assignment PL/pgSQL function public.st_concavehull(public.geometry,double precision,boolean) line 152 at assignment SQL statement "SELECT public.ST_Buffer(public.ST_ConcaveHull(var_geoms[1],least(param_pctconvex + param_pctconvex/var_div),true),var_buf, 'quad_segs=2')" PL/pgSQL function public.st_concavehull(public.geometry,double precision,boolean) line 114 at assignment SQL statement "SELECT public.ST_Buffer(public.ST_ConcaveHull(var_geoms[1],least(param_pctconvex + param_pctconvex/var_div),true),var_buf, 'quad_segs=2')" PL/pgSQL function public.st_concavehull(public.geometry,double precision,boolean) line 114 at assignment PL/pgSQL function public.st_concavehull(public.geometry,double precision,boolean) line 114 at assignment remote SQL command: SELECT public.st_concavehull(public.st_collect(the_geom), 0.7::double precision, true) FROM public.all_month
As far as I know, FDW doesn't have an options to add extra schema to the search_path (https://www.postgresql.org/docs/12/postgres-fdw.html#id-1.11.7.42.10.4) so we can either find a way to qualify all types used in SQL/PLPGSQL functions, even the implicit ones like geometry_dump
above, or we add SET search_path = @extschema@;
to those functions which would ensure that we use the types and functions created by the function.
Change History (19)
comment:1 by , 5 years ago
comment:8 by , 5 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Reopening to remove the search_path and use a proper solution instead. First I'll revert all commits, then push the C fix and then qualify all variables using extension types.
comment:13 by , 5 years ago
C changes: https://github.com/postgis/postgis/pull/499 SQL changes: https://github.com/postgis/postgis/pull/500
These PRs will also address #4549 and several other qualifications that were missing in both the core and the raster extension.
PR proposal: https://github.com/postgis/postgis/pull/497