Skip to content

Commit 29739e7

Browse files
committed
Add pgRouting version check to new procedure
1 parent 6728c4e commit 29739e7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

db/deploy/routing_functions.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@ CREATE OR REPLACE PROCEDURE {schema_name}.routing_prepare_roads_for_routing()
33
LANGUAGE plpgsql
44
AS $$
55

6+
DECLARE pgr_ver TEXT;
67
BEGIN
8+
-- Ensure pgRouting extension exists with at least pgRouting 4.0
9+
IF NOT EXISTS (
10+
SELECT 1 FROM pg_extension WHERE extname = 'pgrouting'
11+
) THEN
12+
RAISE EXCEPTION
13+
'pgRouting extension is not installed. Version >= 4.0 required.';
14+
END IF;
15+
16+
-- Get pgRouting version
17+
SELECT pgr_version() INTO pgr_ver;
18+
19+
-- Enforce minimum version
20+
IF string_to_array(pgr_ver, '.')::INT[] < ARRAY[4,0] THEN
21+
RAISE EXCEPTION
22+
'pgRouting version % detected. Version >= 4.0 required.',
23+
pgr_ver;
24+
END IF;
725

826
DROP TABLE IF EXISTS edges_table;
927
CREATE TEMP TABLE edges_table AS

0 commit comments

Comments
 (0)