From: Raúl Marín Rodríguez Date: Fri, 18 Oct 2019 12:21:24 +0000 (+0000) Subject: Fix schema qualification of internal types X-Git-Tag: 3.0.0~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac1693ab7b2ba16378346e9435fa39ef0aab035c;p=postgis Fix schema qualification of internal types References #4549 git-svn-id: http://svn.osgeo.org/postgis/branches/3.0@17956 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_dump.c b/postgis/lwgeom_dump.c index 133a2d7d0..ae511459c 100644 --- a/postgis/lwgeom_dump.c +++ b/postgis/lwgeom_dump.c @@ -117,7 +117,8 @@ Datum LWGEOM_dump(PG_FUNCTION_ARGS) * 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 @@ -255,7 +256,8 @@ Datum LWGEOM_dump_rings(PG_FUNCTION_ARGS) * 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 diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index b0a2c480b..d8580ab3e 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -1530,12 +1530,8 @@ Datum isvaliddetail(PG_FUNCTION_ARGS) * 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 diff --git a/regress/core/dump.sql b/regress/core/dump.sql index a32fb6950..ec55eb8a7 100644 --- a/regress/core/dump.sql +++ b/regress/core/dump.sql @@ -178,3 +178,15 @@ GEOMETRYCOLLECTION ( ) ) '); + +-- 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; diff --git a/regress/core/dump_expected b/regress/core/dump_expected index 97aba4af4..3a5f574f5 100644 --- a/regress/core/dump_expected +++ b/regress/core/dump_expected @@ -16,3 +16,4 @@ t9|{4}|POLYGON((0 0,0 9,9 9,9 0,0 0),(5 5,5 6,6 6,5 5)) 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)) diff --git a/regress/core/isvaliddetail.sql b/regress/core/isvaliddetail.sql index 41729c7ef..627b15a38 100644 --- a/regress/core/isvaliddetail.sql +++ b/regress/core/isvaliddetail.sql @@ -48,3 +48,13 @@ select '6s', ST_IsValid( 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; + diff --git a/regress/core/isvaliddetail_expected b/regress/core/isvaliddetail_expected index 1ae00d1b6..9b941b2ef 100644 --- a/regress/core/isvaliddetail_expected +++ b/regress/core/isvaliddetail_expected @@ -8,3 +8,4 @@ 6|t|| 6s|t 5r|Valid Geometry +7|f|Self-intersection|POINT(70 400) diff --git a/regress/run_test.pl b/regress/run_test.pl index 786703db1..8f32e5b79 100755 --- a/regress/run_test.pl +++ b/regress/run_test.pl @@ -70,6 +70,7 @@ my $OPT_UPGRADE_PATH = ''; our $OPT_UPGRADE_FROM = ''; my $OPT_UPGRADE_TO = ''; my $VERBOSE = 0; +my $OPT_SCHEMA = 'public'; GetOptions ( 'verbose' => \$VERBOSE, @@ -83,7 +84,8 @@ GetOptions ( 'raster' => \$OPT_WITH_RASTER, 'sfcgal' => \$OPT_WITH_SFCGAL, 'expect' => \$OPT_EXPECT, - 'extensions' => \$OPT_EXTENSIONS + 'extensions' => \$OPT_EXTENSIONS, + 'schema=s' => \$OPT_SCHEMA ); if ( @ARGV < 1 ) @@ -768,6 +770,7 @@ sub run_simple_test . " -v \"tmpfile='$tmpfile'\"" . " -v \"scriptdir=$scriptdir\"" . " -v \"regdir=$REGDIR\"" + . " -v \"schema=$OPT_SCHEMA.\"" . " -tXAq $DB < $sql > $outfile 2>&1"; my $rv = system($cmd);