Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 912275

Summary: dev-db/postgis: postgis_scripts_installed vs. postgis_scripts_released mismatch
Product: Gentoo Linux Reporter: Timo Gurr <timo.gurr>
Component: Current packagesAssignee: Sam James <sam>
Status: RESOLVED FIXED    
Severity: normal CC: active.bowl4259, pgsql-bugs, sam, sci-geosciences, timo.gurr
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=764959
https://bugs.gentoo.org/show_bug.cgi?id=866554
https://bugs.gentoo.org/show_bug.cgi?id=704074
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 945809    
Bug Blocks:    

Description Timo Gurr 2023-08-14 11:29:38 UTC
After installing dev-db/postgis-3.3.3 and upgrading a database with SELECT PostGIS_Extensions_Upgrade();

# SELECT postgis_full_version();

still reports "need upgrade"

Reproducible: Always

Steps to Reproduce:
1.

# SELECT PostGIS_Extensions_Upgrade();
HINWEIS:  Updating extension postgis 3.3.3
                             postgis_extensions_upgrade                             
------------------------------------------------------------------------------------
 Upgrade to version 3.3.3 completed, run SELECT postgis_full_version(); for details
(1 Zeile)

2.

# SELECT postgis_full_version();

postgis_full_version                                                                                                                           
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 POSTGIS="3.3.3 POSTGIS_REVISION" [EXTENSION] (liblwgeom version mismatch: "3.3.3 2355e8e") PGSQL="120" GEOS="3.12.0-CAPI-1.18.0" PROJ="9.2.1" LIBXML="2.11.4" LIBJSON="0.16" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 (Internal)" (core procs from "3.3.3 2355e8e" need upgrade)
(1 Zeile)
Actual Results:  
# SELECT postgis_scripts_installed(), postgis_scripts_released();
 postgis_scripts_installed | postgis_scripts_released 
---------------------------+--------------------------
 3.3.3 2355e8e             | 3.3.3 POSTGIS_REVISION

Expected Results:  
Probably postgis_scripts_installed output should match with postgis_scripts_released output.
Comment 1 Timo Gurr 2024-11-20 12:55:41 UTC
This is still an issue with postgis-3.3.7:

# SELECT PostGIS_Extensions_Upgrade();
HINWEIS:  Updating extension postgis 3.3.5
                             postgis_extensions_upgrade                             
------------------------------------------------------------------------------------
 Upgrade to version 3.3.7 completed, run SELECT postgis_full_version(); for details
(1 Zeile)


# SELECT postgis_full_version();
postgis_full_version                                                                                                                           
------------------------------------------------------------------------------------
 POSTGIS="3.3.7 POSTGIS_REVISION" [EXTENSION] (liblwgeom version mismatch: "3.3.7 a0c7967") PGSQL="120" GEOS="3.12.1-CAPI-1.18.1" PROJ="9.4.1" LIBXML="2.13.5" LIBJSON="0.18" LIBPROTOBUF="1.5.0" WAGYU="0.5.0 (Internal)" (core procs from "3.3.7 a0c7967" need upgrade)
(1 Zeile)


# SELECT postgis_scripts_installed(), postgis_scripts_released();
 postgis_scripts_installed | postgis_scripts_released 
---------------------------+--------------------------
 3.3.7 a0c7967             | 3.3.7 POSTGIS_REVISION
(1 Zeile)
Comment 2 Glenn Brauen 2024-12-02 02:33:59 UTC
Issue continues with dev-db/postgis-3.5.0 and upgrading a database with SELECT PostGIS_Extensions_Upgrade();


# SELECT postgis_scripts_installed(), postgis_scripts_released();
 postgis_scripts_installed | postgis_scripts_released 
---------------------------+--------------------------
 3.5.0 d2c3ca4             | 3.5.0 POSTGIS_REVISION
(1 row)


# SELECT postgis_full_version();
--------------------------------
 POSTGIS="3.5.0 POSTGIS_REVISION" [EXTENSION] PGSQL="160" GEOS="3.12.1-CAPI-1.18.1" SFCGAL="SFCGAL 1.5.2, CGAL 5.6, BOOST 1.84.0" PROJ="9.4.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/var/lib/postgresql/.local/share/proj DATABASE_PATH=/usr/share/proj/proj.db" (compiled against PROJ 9.12.1) LIBXML="2.12.8" LIBJSON="0.18" LIBPROTOBUF="1.5.0" WAGYU="0.5.0 (Internal)" (core procs from "3.5.0 d2c3ca4" need upgrade) (sfcgal procs from "3.5.0 d2c3ca4" need upgrade)
(1 row)
Comment 3 Timo Gurr 2024-12-02 17:33:00 UTC
The issue appears to be caused by the eautoreconf run, just removing it will make things look correct:

postgistest=# CREATE EXTENSION postgis;
CREATE EXTENSION
postgistest=# SELECT postgis_scripts_installed(), postgis_scripts_released();
 postgis_scripts_installed | postgis_scripts_released 
---------------------------+--------------------------
 3.3.7 a0c7967             | 3.3.7 a0c7967
(1 Zeile)

postgistest=# SELECT postgis_full_version();
                                                                        postgis_full_version                                                                        
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
 POSTGIS="3.3.7 a0c7967" [EXTENSION] PGSQL="140" GEOS="3.13.0-CAPI-1.19.0" PROJ="9.4.1" LIBXML="2.13.5" LIBJSON="0.18" LIBPROTOBUF="1.5.0" WAGYU="0.5.0 (Internal)"
(1 Zeile)

I'm no autotools expert but the least hacky way I could come up with that looks somehow sane to me is just adding back the missing include after the eautoreconf run:

--- postgis-3.3.7.ebuild        2024-10-04 19:41:15.000000000 +0200
+++ postgis-3.3.7.ebuild.fixed  2024-12-02 18:29:55.516178254 +0100
@@ -75,6 +75,9 @@
        local AT_M4DIR="macros"
        eautoreconf
 
+       # readd include removed by eautoreconf run to define POSTGIS_REVISION
+       sed -i '2s/^/#include "postgis_revision.h"/' postgis_config.h.in || die
+
        postgres-multi_src_prepare
 }

Which will makes things work as intended as well.

postgistest=# SELECT postgis_scripts_installed(), postgis_scripts_released();
 postgis_scripts_installed | postgis_scripts_released 
---------------------------+--------------------------
 3.3.7 a0c7967             | 3.3.7 a0c7967





Other dity hacks I've tried:


rm postgis_revision.h || die
echo "#define POSTGIS_REVISION POSTGIS_REVISION" > postgis_revision.h || die

results in:

postgistest=# SELECT postgis_scripts_installed(), postgis_scripts_released();
 postgis_scripts_installed | postgis_scripts_released 
---------------------------+--------------------------
 3.3.7 POSTGIS_REVISION    | 3.3.7 POSTGIS_REVISION



sed -e 'POSTGIS_REVISION:a0c7967:g' -i postgis/lwgeom_functions_basic.c

results in:

postgistest=# SELECT postgis_scripts_installed(), postgis_scripts_released();
 postgis_scripts_installed | postgis_scripts_released 
---------------------------+--------------------------
 3.3.7 a0c7967             | 3.3.7 a0c7967
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 17:37:04 UTC
I don't know much about pg at all but I do autotools and the rest.

I can have a look if you give me very naive instructions assuming I have nothing setup to reproduce it.
Comment 5 Timo Gurr 2024-12-02 17:48:09 UTC
It's basically very easy to test, just emerge postgresql+postgis, create a regular user & database and install the extension and check the output:

# su - postgres
$ createuser --pwprompt postgistest
$ createdb -O postgistest postgistest
$ psql -U postgres
postgres=# \connect postgistest
postgistest=# CREATE EXTENSION postgis;
postgistest=# SELECT postgis_scripts_installed(), postgis_scripts_released();

see if the output from both colums (postgis_scripts_installed & postgis_scripts_released) match.

additionally the output of:

postgistest=# SELECT postgis_full_version();

should read:

POSTGIS="3.3.7 a0c7967" [EXTENSION] PGSQL="140" GEOS="3.13.0-CAPI-1.19.0" PROJ="9.4.1" LIBXML="2.13.5" LIBJSON="0.18" LIBPROTOBUF="1.5.0" WAGYU="0.5.0 (Internal)"

and not complaint about version mismatches and needing an upgade:

POSTGIS="3.3.7 POSTGIS_REVISION" [EXTENSION] (liblwgeom version mismatch: "3.3.7 a0c7967") PGSQL="140" GEOS="3.13.0-CAPI-1.19.1" PROJ="9.4.1" LIBXML="2.13.5" LIBJSON="0.18" LIBPROTOBUF="1.5.0" WAGYU="0.5.0 (Internal)" (core procs from "3.3.7 a0c7967" need upgrade)
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-02 18:25:15 UTC
Many thanks for the prompt (and clear) directions. I'll take a look.
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-12-03 01:47:41 UTC
Heh, it's kind of obvious when looking at it. Upstream's `autogen.sh` doesn't call `autoreconf` but just the individual commands instead: notably not including autoheader.

Frustratingly, they keep the autoheader comment but don't actually want to rely on it. See also e.g. https://github.com/postgis/postgis/commit/5c31005664b862de2bb098109d207ac8b4d4c7a1 where they ran afowl of this.
Comment 8 Larry the Git Cow gentoo-dev 2024-12-03 02:44:45 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cec1876c7d43596990f022e9862040fce1edcf39

commit cec1876c7d43596990f022e9862040fce1edcf39
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-03 02:42:34 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-03 02:44:25 +0000

    dev-db/postgis: don't call eautoheader
    
    Upstream commit their own edits to postgres_config.h(.in) *after* vanilla
    autoheader has run which means that running it ourselves clobbers those
    changes. Stop doing that.
    
    This would lead to a mismatched version being reported at least at runtime.
    
    Thanks to Timo Gurr for the debugging and help reproducing it.
    
    Closes: https://bugs.gentoo.org/912275
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-db/postgis/postgis-3.5.0-r1.ebuild | 137 +++++++++++++++++++++++++++++++++
 1 file changed, 137 insertions(+)
Comment 9 Glenn Brauen 2024-12-03 03:11:19 UTC
Confirming that preventing autoheader from running fixes the problem. After emerging dev-db/postgis/postgis-3.5.0-r1.ebuild:

# SELECT postgis_scripts_installed(), postgis_scripts_released();
 postgis_scripts_installed | postgis_scripts_released 
---------------------------+--------------------------
 3.5.0 d2c3ca4             | 3.5.0 d2c3ca4
(1 row)

and 

# SELECT postgis_full_version();

no longer suggests that upgrades are still needed after I have run

# Select postgis_extensions_upgrade();

Thank you for the fix!
Comment 10 Timo Gurr 2024-12-03 09:23:02 UTC
(In reply to Larry the Git Cow from comment #8)
> The bug has been closed via the following commit(s):
> 
> https://gitweb.gentoo.org/repo/gentoo.git/commit/
> ?id=cec1876c7d43596990f022e9862040fce1edcf39

Huge thanks for the fix! But could you please also apply it to the other available PostGIS versions 3.3.x and 3.4.x as well? There are sadly various reasons users can't just always upgrade to the latest PostGIS version.
Comment 11 Larry the Git Cow gentoo-dev 2024-12-03 09:30:23 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bdfed7012cdb0845fbd9ecd009760f383a56db70

commit bdfed7012cdb0845fbd9ecd009760f383a56db70
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-12-03 09:29:39 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-03 09:30:04 +0000

    dev-db/postgis: backport eautoheader fix
    
    Backport the fix from cec1876c7d43596990f022e9862040fce1edcf39.
    
    Closes: https://bugs.gentoo.org/912275
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-db/postgis/postgis-3.3.7-r1.ebuild | 142 +++++++++++++++++++++++++++++++++
 dev-db/postgis/postgis-3.4.3-r1.ebuild | 140 ++++++++++++++++++++++++++++++++
 2 files changed, 282 insertions(+)