Skip to content

Commit c41237e

Browse files
committed
fix(postgis): remove custom sfcgal package dependency
Updated postgis.nix to use nixpkgs sfcgal instead of our custom package, eliminating the need to maintain a separate sfcgal build definition.
1 parent f5e43a4 commit c41237e

File tree

6 files changed

+51
-60
lines changed

6 files changed

+51
-60
lines changed

nix/ext/pgrouting.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,18 @@ let
4949
inherit hash;
5050
};
5151

52+
patches = lib.optionals (version == "3.4.1" && lib.versionAtLeast postgresql.version "17") [
53+
./pgrouting/pgrouting-3.4.1-pg17.patch
54+
];
55+
5256
#disable compile time warnings for incompatible pointer types only on macos and pg16
5357
NIX_CFLAGS_COMPILE = lib.optionalString (
5458
stdenv.isDarwin && lib.versionAtLeast postgresql.version "16"
5559
) "-Wno-error=int-conversion -Wno-error=incompatible-pointer-types";
5660

5761
cmakeFlags = [
5862
"-DPOSTGRESQL_VERSION=${postgresql.version}"
63+
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
5964
]
6065
++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") [
6166
"-DCMAKE_MACOSX_RPATH=ON"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From ce195442200452ae50b63528647e3837e9f121e0 Mon Sep 17 00:00:00 2001
2+
From: Yvan Sraka <yvan@sraka.xyz>
3+
Date: Thu, 4 Dec 2025 19:33:44 +0100
4+
Subject: [PATCH] Fix PostgreSQL 17 compatibility in SPI_getvalue calls
5+
6+
SPI_getvalue already returns a char* in PostgreSQL 17, so wrapping
7+
it in DatumGetCString (which expects a Datum) causes a compilation
8+
error. This patch removes the unnecessary DatumGetCString wrapper
9+
in both get_check_data.c and trsp.c files.
10+
---
11+
src/common/get_check_data.c | 2 +-
12+
src/trsp/trsp.c | 4 ++--
13+
2 files changed, 3 insertions(+), 3 deletions(-)
14+
15+
diff --git a/src/common/get_check_data.c b/src/common/get_check_data.c
16+
index 85ea70d..82a81d1 100644
17+
--- a/src/common/get_check_data.c
18+
+++ b/src/common/get_check_data.c
19+
@@ -304,5 +304,5 @@ pgr_SPI_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
20+
*/
21+
char*
22+
pgr_SPI_getText(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
23+
- return DatumGetCString(SPI_getvalue(*tuple, *tupdesc, info.colNumber));
24+
+ return SPI_getvalue(*tuple, *tupdesc, info.colNumber);
25+
}
26+
diff --git a/src/trsp/trsp.c b/src/trsp/trsp.c
27+
index 7f9397a..52b68dd 100644
28+
--- a/src/trsp/trsp.c
29+
+++ b/src/trsp/trsp.c
30+
@@ -114,8 +114,8 @@ fetch_restrict(HeapTuple *tuple, TupleDesc *tupdesc,
31+
if (isnull)
32+
elog(ERROR, "to_cost contains a null value");
33+
rest->to_cost = DatumGetFloat8(binval);
34+
- char *str = DatumGetCString(SPI_getvalue(*tuple, *tupdesc,
35+
- restrict_columns->via_path));
36+
+ char *str = SPI_getvalue(*tuple, *tupdesc,
37+
+ restrict_columns->via_path);
38+
39+
// PGR_DBG("restriction: %f, %i, %s", rest->to_cost, rest->target_id, str);

nix/ext/postgis.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
nixosTests,
1717
callPackage,
1818
buildEnv,
19+
sfcgal,
1920
}:
2021

2122
let
22-
sfcgal = callPackage ../packages/sfcgal.nix { };
2323
gdal = callPackage ./gdal.nix { inherit postgresql; };
2424
pname = "postgis";
2525

nix/packages/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP;
4949
pg_regress = makePgRegress activeVersion;
5050
run-testinfra = pkgs.callPackage ./run-testinfra.nix { };
51-
sfcgal = pkgs.callPackage ./sfcgal.nix { };
5251
show-commands = pkgs.callPackage ./show-commands.nix { };
5352
start-client = pkgs.callPackage ./start-client.nix {
5453
psql_15 = self'.packages."psql_15/bin";

nix/packages/sfcgal.nix

Lines changed: 0 additions & 52 deletions
This file was deleted.

nix/tests/expected/pgrouting.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ select * from pgr_dijkstra(
1919
1, -- start node
2020
4 -- end node
2121
);
22-
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
23-
-----+----------+-----------+---------+------+------+------+----------
24-
1 | 1 | 1 | 4 | 1 | 1 | 1 | 0
25-
2 | 2 | 1 | 4 | 2 | 2 | 1 | 1
26-
3 | 3 | 1 | 4 | 3 | 3 | 1 | 2
27-
4 | 4 | 1 | 4 | 4 | -1 | 0 | 3
22+
seq | path_seq | node | edge | cost | agg_cost
23+
-----+----------+------+------+------+----------
24+
1 | 1 | 1 | 1 | 1 | 0
25+
2 | 2 | 2 | 2 | 1 | 1
26+
3 | 3 | 3 | 3 | 1 | 2
27+
4 | 4 | 4 | -1 | 0 | 3
2828
(4 rows)
2929

3030
drop schema v cascade;

0 commit comments

Comments
 (0)