Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
How to rewrite postgres functions which reference postgis lib?

I recently upgraded my postgres version from 9.4 to 10.1. At the same time, I wanted to upgrade postgis from version 2.1 to version 3.

What I did is just dump my database and restore it on my new postgres. But here is the problem I face. Since a lot of functions reference the postgis library with AS '$libdir/postgis-2.1', I get an error saying it can't found $libdir/postgis-2.1.

Of course it can't since the libraries directory of my new postgres only contains postgis-3.so. But then how to tell my function to use this one?

I already found a trick, creating a link named postgis-2.1.so and pointing to postgis-3.so. But this is really an ugly way to do, and I don't want to have to create a new link every times I will upgrade postgis.

I also tried to dump functions, sed it and restore it like this:

pg_dump -U postgres -Fc -s -f db_schema my_db
sed -i -e 's/postgis-2.1/postgis-3/g' db_schema
pg_restore -l db_schema | grep FUNCTION > functions
pg_restore -U postgres -d my_db -L functions db_schema

But it seems that pg_restore does not like the fact I sed this file since I get this error:

pg_restore: [custom archiver] could not read from input file: end of file

Is there a clean way to do this upgrade or is my symlink the only solution here?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Have you tried to follow the documentation?

It seems you're missing enabling PostGIS.

-- Enable PostGIS (as of 3.0 contains just geometry/geography)
CREATE EXTENSION postgis;
-- enable raster support (for 3+)
CREATE EXTENSION postgis_raster;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- Enable PostGIS Advanced 3D
-- and other geoprocessing algorithms
-- sfcgal not available with all distributions
CREATE EXTENSION postgis_sfcgal;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- rule based standardizer
CREATE EXTENSION address_standardizer;
-- example rule data set
CREATE EXTENSION address_standardizer_data_us;
-- Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda