[postgis-tickets] r17958 - Fix schema qualification of internal types

Raul raul at rmr.ninja
Fri Oct 18 05:23:45 PDT 2019


Author: algunenano
Date: 2019-10-18 05:23:44 -0700 (Fri, 18 Oct 2019)
New Revision: 17958

Modified:
   branches/2.5/NEWS
   branches/2.5/postgis/lwgeom_dump.c
   branches/2.5/postgis/lwgeom_geos.c
   branches/2.5/regress/dump.sql
   branches/2.5/regress/dump_expected
   branches/2.5/regress/isvaliddetail.sql
   branches/2.5/regress/isvaliddetail_expected
   branches/2.5/regress/run_test.pl
Log:
Fix schema qualification of internal types

References #4549



Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS	2019-10-18 12:22:22 UTC (rev 17957)
+++ branches/2.5/NEWS	2019-10-18 12:23:44 UTC (rev 17958)
@@ -19,6 +19,7 @@
   - #4536, Fix leak in lwcollection_from_wkb_state (Raúl Marín)
   - #4537, Fix leak in WKT collection parser (Raúl Marín)
   - #4547, Fix AddRasterConstraints handling of empty tables (Sandro Santilli)
+  - #4549, Fix schema qualification of internal types (Raúl Marín)
 
 
 PostGIS 2.5.3

Modified: branches/2.5/postgis/lwgeom_dump.c
===================================================================
--- branches/2.5/postgis/lwgeom_dump.c	2019-10-18 12:22:22 UTC (rev 17957)
+++ branches/2.5/postgis/lwgeom_dump.c	2019-10-18 12:23:44 UTC (rev 17958)
@@ -118,7 +118,8 @@
 		 * Build a tuple description for an
 		 * geometry_dump tuple
 		 */
-		tupdesc = RelationNameGetTupleDesc("geometry_dump");
+		get_call_result_type(fcinfo, 0, &tupdesc);
+		BlessTupleDesc(tupdesc);
 
 		/*
 		 * generate attribute metadata needed later to produce
@@ -256,7 +257,8 @@
 		 * Build a tuple description for an
 		 * geometry_dump tuple
 		 */
-		tupdesc = RelationNameGetTupleDesc("geometry_dump");
+		get_call_result_type(fcinfo, 0, &tupdesc);
+		BlessTupleDesc(tupdesc);
 
 		/*
 		 * generate attribute metadata needed later to produce

Modified: branches/2.5/postgis/lwgeom_geos.c
===================================================================
--- branches/2.5/postgis/lwgeom_geos.c	2019-10-18 12:22:22 UTC (rev 17957)
+++ branches/2.5/postgis/lwgeom_geos.c	2019-10-18 12:23:44 UTC (rev 17958)
@@ -1489,12 +1489,8 @@
 	 * Build a tuple description for a
 	 * valid_detail tuple
 	 */
-	tupdesc = RelationNameGetTupleDesc("valid_detail");
-	if ( ! tupdesc )
-	{
-		lwpgerror("TYPE valid_detail not found");
-		PG_RETURN_NULL();
-	}
+	get_call_result_type(fcinfo, 0, &tupdesc);
+	BlessTupleDesc(tupdesc);
 
 	/*
 	 * generate attribute metadata needed later to produce

Modified: branches/2.5/regress/dump.sql
===================================================================
--- branches/2.5/regress/dump.sql	2019-10-18 12:22:22 UTC (rev 17957)
+++ branches/2.5/regress/dump.sql	2019-10-18 12:23:44 UTC (rev 17958)
@@ -178,3 +178,15 @@
 	)
 )
 ');
+
+-- Check that it works without the extension schema being available
+BEGIN;
+SET search_path TO pg_catalog;
+WITH data AS
+(
+    SELECT 'POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))':: :schema geometry as geom
+)
+SELECT	't12',
+	:schema ST_AsText((public.ST_Dump(geom)).geom),
+	:schema ST_AsText((public.ST_DumpRings(geom)).geom) FROM data;
+ROLLBACK;

Modified: branches/2.5/regress/dump_expected
===================================================================
--- branches/2.5/regress/dump_expected	2019-10-18 12:22:22 UTC (rev 17957)
+++ branches/2.5/regress/dump_expected	2019-10-18 12:23:44 UTC (rev 17958)
@@ -16,3 +16,4 @@
 t9|{5,1}|POLYGON((0 0,0 9,9 9,9 0,0 0),(5 5,5 6,6 6,5 5))
 t10|0
 t11|0
+t12|POLYGON((0 0,0 1,1 1,1 0,0 0))|POLYGON((0 0,0 1,1 1,1 0,0 0))

Modified: branches/2.5/regress/isvaliddetail.sql
===================================================================
--- branches/2.5/regress/isvaliddetail.sql	2019-10-18 12:22:22 UTC (rev 17957)
+++ branches/2.5/regress/isvaliddetail.sql	2019-10-18 12:23:44 UTC (rev 17958)
@@ -48,3 +48,13 @@
 select '5r', ST_IsValidReason(
 'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 1);
 
+-- Check that it works without the extension schema being available
+BEGIN;
+SET search_path TO pg_catalog;
+select 7, valid, reason, :schema st_astext(location) FROM (
+  SELECT (:schema ST_IsValidDetail(
+    'POLYGON ((70 250, 70 500, 80 400, 40 400, 70 250))':: :schema geometry
+  )).*
+) foo;
+ROLLBACK;
+

Modified: branches/2.5/regress/isvaliddetail_expected
===================================================================
--- branches/2.5/regress/isvaliddetail_expected	2019-10-18 12:22:22 UTC (rev 17957)
+++ branches/2.5/regress/isvaliddetail_expected	2019-10-18 12:23:44 UTC (rev 17958)
@@ -8,3 +8,4 @@
 6|t||
 6s|t
 5r|Valid Geometry
+7|f|Self-intersection|POINT(70 400)

Modified: branches/2.5/regress/run_test.pl
===================================================================
--- branches/2.5/regress/run_test.pl	2019-10-18 12:22:22 UTC (rev 17957)
+++ branches/2.5/regress/run_test.pl	2019-10-18 12:23:44 UTC (rev 17958)
@@ -70,6 +70,7 @@
 our $OPT_UPGRADE_FROM = '';
 my $OPT_UPGRADE_TO = '';
 my $VERBOSE = 0;
+my $OPT_SCHEMA = 'public';
 
 GetOptions (
 	'verbose' => \$VERBOSE,
@@ -83,7 +84,8 @@
 	'raster' => \$OPT_WITH_RASTER,
 	'sfcgal' => \$OPT_WITH_SFCGAL,
 	'expect' => \$OPT_EXPECT,
-	'extensions' => \$OPT_EXTENSIONS
+	'extensions' => \$OPT_EXTENSIONS,
+	'schema=s' => \$OPT_SCHEMA
 	);
 
 if ( @ARGV < 1 )
@@ -726,7 +728,8 @@
           . " -v \"tmpfile='$tmpfile'\""
           . " -v \"scriptdir=$scriptdir\""
           . " -v \"regdir=$REGDIR\""
-          . " -tXA $DB < $sql > $outfile 2>&1";
+          . " -v \"schema=$OPT_SCHEMA.\""
+          . " -tXAq $DB < $sql > $outfile 2>&1";
 	my $rv = system($cmd);
 
 	# Check for ERROR lines



More information about the postgis-tickets mailing list