]> granicus.if.org Git - postgis/commitdiff
Fix scan type detection function to work with nested nodes
authorSandro Santilli <strk@keybit.net>
Tue, 24 Feb 2015 08:59:45 +0000 (08:59 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 24 Feb 2015 08:59:45 +0000 (08:59 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13277 b70326c6-7e19-0410-871a-916f4a2858ee

regress/regress_index.sql

index 0b27132d6827a47038016117e31873f10e85bac1..582cca543f5178081f5ad06691162b8b77b77005 100644 (file)
@@ -3,14 +3,25 @@
 
 --- test some of the searching capabilities
 
-CREATE FUNCTION qnodes(q text) RETURNS text
+CREATE OR REPLACE FUNCTION qnodes(q text) RETURNS text
 LANGUAGE 'plpgsql' AS
 $$
 DECLARE
   exp TEXT;
+  mat TEXT[];
+  ret TEXT[];
 BEGIN
-  EXECUTE 'EXPLAIN ' || q INTO exp;
-  RETURN (regexp_matches(exp, ' *(.*Scan)'))[1];
+  FOR exp IN EXECUTE 'EXPLAIN ' || q
+  LOOP
+    --RAISE NOTICE 'EXP: %', exp;
+    mat := regexp_matches(exp, ' *(?:-> *)?(.*Scan)');
+    --RAISE NOTICE 'MAT: %', mat;
+    IF mat IS NOT NULL THEN
+      ret := array_append(ret, mat[1]);
+    END IF;
+    --RAISE NOTICE 'RET: %', ret;
+  END LOOP;
+  RETURN array_to_string(ret,',');
 END;
 $$;