Skip to content

"Undefined function" error when SEARCH_PATH is different than the schema PostGIS is installed in #73

@dece

Description

@dece

Hi,

If your PostgreSQL role has a different SEARCH_PATH than public or the one PostGIS has been installed in with the CREATE EXTENSION postgis SCHEMA xxx, retrieving entities from database will fail with the following error:

SQLSTATE[42883]: Undefined function: 7 ERROR:  function st_asewkt(public.geometry) does not exist
LINE 2: ...o.src AS src, o.cd_nom AS cd_nom, o.date AS date, ST_AsEWKT(...
                                                             ^
Hint: No function matches the given name and argument types.
You might need to add explicit type casts`

Altering the role to use public as search path makes the problem disappear. The problem can also be fixed by specifying the function schema directly in PostGISType::convertToPHPValueSQL.

-       return sprintf('ST_AsEWKT(%s)', $sqlExpr);
+       return sprintf('public.ST_AsEWKT(%s)', $sqlExpr);

I am not sure what the fix should be because I am not sure what are the guarantees that I left behind when I altered the search path for this role, but being able to specify the schema where PostGIS has been installed might be nice?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions