pg_cron icon indicating copy to clipboard operation
pg_cron copied to clipboard

Makefile does not generate versioned .sql files

Open mtuncer opened this issue 6 years ago • 3 comments

When you issue make, it generates following extension initialization scripts

pg_cron--1.0--1.1.sql
pg_cron--1.1--1.2.sql
pg_cron--1.0.sql 

afterwards when you want to to do create extension pg_cron you might get following error for older versions of postgres

ERROR:  could not stat file "/usr/share/postgresql/9.5/extension/pg_cron--1.2.sql": No such file or directory
``
Issue is originally reported by a user on ubuntu 16.04  and PG9.5. 

I tested this with PG12 on Mac, it seems okay.

mtuncer avatar Sep 27 '19 07:09 mtuncer

We have the same issue after an RHEL7 upgdate:

dba@pgcluster # create extension pg_cron; ERROR: could not stat file "/usr/pgsql-9.6/share/extension/pg_cron--1.2.sql": No such file or directory Time: 3.641 ms dba@pgcluster # \q postgres@myhost $ ll /usr/pgsql-9.6/share/extension/pg_cron* -rw-r--r--. 1 root root 101 Sep 6 17:05 /usr/pgsql-9.6/share/extension/pg_cron--1.0--1.1.sql -rw-r--r--. 1 root root 2034 Sep 6 17:05 /usr/pgsql-9.6/share/extension/pg_cron--1.0.sql -rw-r--r--. 1 root root 155 Sep 6 17:05 /usr/pgsql-9.6/share/extension/pg_cron--1.1--1.2.sql -rw-r--r--. 1 root root 121 Sep 6 17:05 /usr/pgsql-9.6/share/extension/pg_cron.control postgres@myhost $ rpm -aq | grep pg_cron pg_cron_96-1.2.0-1.rhel7.x86_64

Any bugfix?

mzwettler2 avatar Sep 30 '19 11:09 mzwettler2

Using the official Docker image (which already has the common repo installed).

FROM postgres:9.6

RUN set -eux \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        postgresql-$PG_MAJOR-cron

Then I build

$ docker build --tag example .

And run

$ docker run --rm -it example
...
STATEMENT:  CREATE EXTENSION IF NOT EXISTS pg_cron
ERROR:  could not stat file "/usr/share/postgresql/9.6/extension/pg_cron--1.2.sql": No such file or directory

The files installed are:

# ls -l /usr/share/postgresql/9.6/extension/pg_cron*
-rw-r--r-- 1 root root  101 Oct 26 07:23 /usr/share/postgresql/9.6/extension/pg_cron--1.0--1.1.sql
-rw-r--r-- 1 root root 2034 Oct 26 07:23 /usr/share/postgresql/9.6/extension/pg_cron--1.0.sql     
-rw-r--r-- 1 root root  155 Oct 26 07:23 /usr/share/postgresql/9.6/extension/pg_cron--1.1--1.2.sql
-rw-r--r-- 1 root root  121 Oct 26 07:23 /usr/share/postgresql/9.6/extension/pg_cron.control

And the control file contents:

comment = 'Job scheduler for PostgreSQL'
default_version = '1.2'
module_pathname = '$libdir/pg_cron'     
relocatable = false

AnthonyMastrean avatar Dec 12 '19 21:12 AnthonyMastrean

I fix it by this command: ln -s /usr/share/postgresql/9.6/extension/pg_cron--1.0.sql /usr/share/postgresql/9.6/extension/pg_cron--1.2.sql

alimzadeh avatar Apr 14 '20 09:04 alimzadeh