pgLatLon
annotate create_test_db.data.sql @ 79:16787a19a325
Do not return CSTRING to static memory
Avoids wrong pfree under certain circumstances
(e.g. array_agg on empty EBOX or ECLUSTER).
Avoids wrong pfree under certain circumstances
(e.g. array_agg on empty EBOX or ECLUSTER).
| author | jbe |
|---|---|
| date | Thu Oct 23 10:16:01 2025 +0200 (4 days ago) |
| parents | 3cbce515387f |
| children |
| rev | line source |
|---|---|
| jbe@0 | 1 |
| jbe@10 | 2 CREATE OR REPLACE FUNCTION tmp_three_points() |
| jbe@10 | 3 RETURNS epoint[] |
| jbe@10 | 4 LANGUAGE plpgsql VOLATILE AS $$ |
| jbe@10 | 5 DECLARE |
| jbe@10 | 6 p1 epoint; |
| jbe@10 | 7 p2 epoint; |
| jbe@10 | 8 p3 epoint; |
| jbe@10 | 9 BEGIN |
| jbe@10 | 10 p1 := epoint((asin(2*random()-1) / pi()) * 180, (2*random()-1) * 180); |
| jbe@10 | 11 p2 := epoint(latitude(p1) + (2*random()-1), longitude(p1) + cos(latitude(p1)/180*pi()) * (2*random()-1)); |
| jbe@10 | 12 p3 := epoint(latitude(p1) + (2*random()-1), longitude(p1) + cos(latitude(p1)/180*pi()) * (2*random()-1)); |
| jbe@10 | 13 RETURN ARRAY[p1, p2, p3]; |
| jbe@10 | 14 END; |
| jbe@10 | 15 $$; |
| jbe@10 | 16 |
| jbe@46 | 17 INSERT INTO "test" ("location", "surrounding", "multipoint", "triangle", "votes") SELECT |
| jbe@0 | 18 epoint((asin(2*random()-1) / pi()) * 180, (2*random()-1) * 180), |
| jbe@10 | 19 ecircle((asin(2*random()-1) / pi()) * 180, (2*random()-1) * 180, -ln(1-random()) * 1000), |
| jbe@10 | 20 ecluster_create_multipoint(tmp_three_points()), |
| jbe@46 | 21 ecluster_create_polygon(tmp_three_points()), |
| jbe@46 | 22 floor(random()*101) |
| jbe@0 | 23 FROM generate_series(1, 10000); |
| jbe@0 | 24 |
| jbe@10 | 25 DROP FUNCTION tmp_three_points(); |
| jbe@46 | 26 |