Skip to content

Commit 89e09ec

Browse files
committed
[TEST] adding a test function
1 parent 23acbaa commit 89e09ec

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.5.4-6764-7064964 release/2.5
1+
v2.5.4-6765-bb77143 release/2.5

sql/common/utilities_pgr.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ BEGIN
214214
IF (sql IS NULL) THEN
215215
RETURN o_sql;
216216
ELSE
217-
RETURN regexp_replace(sql, '(.)* as ', '', 'i');
217+
RETURN regexp_replace(regexp_replace(regexp_replace(sql, '\s(as)\s', '___foo___', 'i'), '^.*___foo___', '','i'), ';$', '');
218218
END IF;
219219
END
220220
$BODY$

tools/testers/no_crash_test.sql

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
CREATE OR REPLACE FUNCTION no_crash_test(func TEXT, params TEXT[], subs TEXT[])
3+
RETURNS SETOF TEXT AS
4+
$BODY$
5+
DECLARE
6+
mp TEXT[];
7+
q1 TEXT;
8+
q TEXT;
9+
separator TEXT;
10+
BEGIN
11+
FOR i IN 0..array_length(params, 1) LOOP
12+
separator = ' ';
13+
mp := params;
14+
IF i != 0 THEN
15+
mp[i] = subs[i];
16+
END IF;
17+
18+
q1 := 'SELECT * FROM ' || $1 || ' (';
19+
20+
FOR i IN 1..array_length(mp, 1) LOOP
21+
q1 := q1 || separator || mp[i];
22+
separator :=',';
23+
END LOOP;
24+
25+
q1 := q1 || ')';
26+
27+
28+
29+
RETURN query SELECT * FROM lives_ok(q1);
30+
IF i = 0 THEN
31+
RETURN query SELECT * FROM isnt_empty(q1);
32+
ELSE
33+
RETURN query SELECT * FROM is_empty(q1);
34+
END IF;
35+
36+
END LOOP;
37+
38+
END
39+
$BODY$
40+
LANGUAGE plpgsql VOLATILE;

tools/testers/setup_db.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ CREATE EXTENSION pgrouting;
2222
BEGIN;
2323

2424
\i sampledata.sql
25+
\i vrppdtw_data.sql
26+
\i vrpOneDepot.data
2527
\i innerQuery.sql
2628
\i innerQuery_old.sql
2729
\i inner_styles.sql
2830
\i old_inner_styles.sql
31+
\i no_crash_test.sql
2932

3033
END;

0 commit comments

Comments
 (0)