postgis / docker-postgis

Docker image for PostGIS
https://hub.docker.com/r/postgis/postgis/
MIT License
1.37k stars 462 forks source link

missing address_standardizer extension #219

Closed rahul-ve closed 3 years ago

rahul-ve commented 3 years ago

Hi,

Using image postgis:13-master

I was trying to install the extension address_standardizer but was failing with the below error: ERROR: could not open extension control file "/usr/share/postgresql/13/extension/address_standardizer.control": No such file or directory and it depends on pcre as described in the docs and during the postgis build, it is supposed to build it if pcre was found to be present. Looks like this was not the case.

Any suggestions on how to get address_standardizer?

Thanks Rahul

ImreSamu commented 3 years ago

Thank you !

I can replicate with the alpine based postgis image. ( tested with postgis/postgis:13-3.1-alpine ) probably the current alpine build script is not perfect - I can't see the pcre in ( ./13-3.1/alpine/Dockerfile )

Any suggestions on how to get address_standardizer?

If you can : please use the debian based images ( no alpine in the docker tags );

my test example:

$ docker run --name pgis_test -e POSTGRES_PASSWORD=M9secret -d postgis/postgis:13-3.1
47f24f227ee82c3c4340ceff6ffd9673dc9aed0aa9cd541caacd3dd2b74f5619

$ docker run --rm -it --link pgis_test:postgres postgis/postgis:13-3.1 \
>      sh -c 'PGPASSWORD=M9secret exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
psql (13.1 (Debian 13.1-1.pgdg100+1))
Type "help" for help.

postgres=# create extension address_standardizer;
CREATE EXTENSION
postgres=# \dx
                                                                    List of installed extensions
          Name          | Version |   Schema   |                                                     Description                                                     
------------------------+---------+------------+---------------------------------------------------------------------------------------------------------------------
 address_standardizer   | 3.1.0   | public     | Used to parse an address into constituent elements. Generally used to support geocoding address normalization step.
 fuzzystrmatch          | 1.1     | public     | determine similarities and distance between strings
 plpgsql                | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis                | 3.1.0   | public     | PostGIS geometry and geography spatial types and functions
 postgis_tiger_geocoder | 3.1.0   | tiger      | PostGIS tiger geocoder and reverse geocoder
 postgis_topology       | 3.1.0   | topology   | PostGIS topology spatial types and functions
(6 rows)

postgres=# SELECT num, street, city, zip, zipplus
FROM parse_address('1 Devonshire Place, Boston, MA 02109-1234') AS a;
 num |      street      |  city  |  zip  | zipplus 
-----+------------------+--------+-------+---------
 1   | Devonshire Place | Boston | 02109 | 1234
(1 row)

postgres=# 
rahul-ve commented 3 years ago

Thanks @ImreSamu for the quick reply. I used 13-master Debian image, will try 13-3.1

ImreSamu commented 3 years ago

@rahul-ve :

it is supposed to build it if pcre was found to be present.

imho: if you want - you can create a fix ( and a "Pull Request" )

my suggestions based on your pcre theory ( not tested ) :

rahul-ve commented 3 years ago

@ImreSamu Sure let me work on it.

rahul-ve commented 3 years ago

@ImreSamu adding libpcre3-dev built the address_standardizer extension. Note libpcre3 is the old version of PCRE; newer version is libpcre2 but using this fails the build as the /usr/include/pcre.h is hardcoded in postgis configure script. libpcre2 header file is /usr/include/pcre2.h.

When testing with the files in the 13-master folder, I am seeing the below msg in the log, is that expected?

waiting for server to start....2021-01-21 10:51:46.982 UTC [48] LOG:  starting PostgreSQL 13.1 (Debian 13.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-01-21 10:51:47.063 UTC [48] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-01-21 10:51:47.331 UTC [49] LOG:  database system was shut down at 2021-01-21 10:51:45 UTC
2021-01-21 10:51:47.399 UTC [48] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/10_postgis.sh
/docker-entrypoint-initdb.d/10_postgis.sh: 9: /docker-entrypoint-initdb.d/10_postgis.sh: Bad substitution

PostgreSQL Database directory appears to contain a database; Skipping initialization

and the list of DBs


postgres=# \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges
-----------+----------+----------+------------+------------+-----------------------
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 |
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(3 rows)
ImreSamu commented 3 years ago

When testing with the files in the 13-master folder, I am seeing the below msg in the log, is that expected?

not expected ; something strange ..

$ docker pull postgis/postgis:13-master
13-master: Pulling from postgis/postgis
Digest: sha256:2bf24b41e751d6aa746cc953643672e1e70a23f52deb4ce1ec44dca67c40855a
Status: Image is up to date for postgis/postgis:13-master
docker.io/postgis/postgis:13-master

$ docker run --name pgis13m_test -e POSTGRES_PASSWORD=M9secpw -d postgis/postgis:13-master
538ad74d25485235dd6b1a858b30a86640cf3d75caf7ed6de88351453b313d96

$ docker logs  pgis13m_test
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2021-01-21 12:47:18.663 UTC [47] LOG:  starting PostgreSQL 13.1 (Debian 13.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-01-21 12:47:18.664 UTC [47] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-01-21 12:47:18.669 UTC [48] LOG:  database system was shut down at 2021-01-21 12:47:18 UTC
2021-01-21 12:47:18.674 UTC [47] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/10_postgis.sh
CREATE DATABASE
Loading PostGIS extensions into template_postgis
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION

adding libpcre3-dev built the address_standardizer extension.

just create a pull request ... :)