#5236 closed defect (wontfix)

ERROR: type "raster" is only a shell

Reported by: marc3932 Owned by: pramsey
Priority: medium Milestone: PostGIS 3.2.4
Component: postgis Version: 3.2.x
Keywords: postgis_raster Cc:

Description

— Platform:

Windows Server 2019
PostgreSQL 12.12
Postgis 3.2.3
SELECT postgis_full_version();

"POSTGIS=""3.2.3 3.2.3"" [EXTENSION] PGSQL=""120"" GEOS=""3.10.3-CAPI-1.16.1"" PROJ=""7.2.1"" LIBXML=""2.9.9"" LIBJSON=""0.12"" LIBPROTOBUF=""1.2.1"" WAGYU=""0.5.0 (Internal)"" (raster procs from ""2.4.4 r16526"" need upgrade)"

NOTE: postgis 3.2.3 and raster 2.4.4

— Upgrade the Postgis Extensions

SELECT postgis_extensions_upgrade();

NOTICE: Packaging extension postgis_raster

ERROR: type "raster" is only a shell

CONTEXT: SQL statement

"CREATE EXTENSION postgis_raster SCHEMA public VERSION unpackaged;

ALTER EXTENSION postgis_raster UPDATE TO "3.2.3""

PL/pgSQL function postgis_extensions_upgrade() line 71 at EXECUTE

SQL state: 42704

QUESTIONS:

Why the extension upgrade returns "ERROR: type "raster" is only a shell" ???

Is this another bug ???

Is there any other workaround for this issue besides "uninstall_rtpostgis.sql" described below ???

—SOLUTION:

— uninstall postgis_raster

psql

\c rev

\i 'C:\\Program Files\\PostgreSQL\\12\\share\\contrib\\postgis-3.2\\uninstall_rtpostgis.sql'
SELECT postgis_extensions_upgrade();

"Upgrade completed, run SELECT postgis_full_version(); for details"

NOTICE: Extension postgis_raster is not available or not packagable for some reason

NOTICE: Extension postgis_sfcgal is not available or not packagable for some reason

NOTICE: Extension postgis_topology is not available or not packagable for some reason

NOTICE: Extension postgis_tiger_geocoder is not available or not packagable for some reason

Successfully run. Total query runtime: 144 msec. 1 rows affected.

SELECT postgis_full_version();

"POSTGIS=""3.2.3 3.2.3"" [EXTENSION] PGSQL=""120"" GEOS=""3.10.3-CAPI-1.16.1"" PROJ=""7.2.1"" LIBXML=""2.9.9"" LIBJSON=""0.12"" LIBPROTOBUF=""1.2.1"" WAGYU=""0.5.0 (Internal)"""

CREATE EXTENSION postgis_raster;

CREATE EXTENSION

Query returned successfully in 227 msec.

SELECT postgis_full_version();

"POSTGIS=""3.2.3 3.2.3"" [EXTENSION] PGSQL=""120"" GEOS=""3.10.3-CAPI-1.16.1"" PROJ=""7.2.1"" GDAL=""GDAL 3.4.3, released 2022/04/22 GDAL_DATA not found"" LIBXML=""2.9.9"" LIBJSON=""0.12"" LIBPROTOBUF=""1.2.1"" WAGYU=""0.5.0 (Internal)"" RASTER"

SELECT * FROM pg_available_extensions WHERE name LIKE 'postgis%';

"name" "default_version" "installed_version" "comment"

"postgis" "3.2.3" "3.2.3" "PostGIS geometry and geography spatial types and functions"

"postgis_raster" "3.2.3" "3.2.3" "PostGIS raster types and functions"

DROP EXTENSION postgis_raster;

DROP EXTENSION

Query returned successfully in 94 msec.


I appreciate the assistance to clarify my questions.

Thanks,

Marcelo Marques | Principal Product Engineer | Esri - www.esri.com |

Change History (4)

comment:1 by marc3932, 20 months ago

PostgreSQL Documentation https://www.postgresql.org/docs/current/sql-createtype.html

  • There are five forms of CREATE TYPE, as shown in the syntax synopsis above.
  • They respectively create a composite type, an enum type, a range type, a base type, or a shell type.
  • The first four of these are discussed in turn below.
  • A shell type is simply a placeholder for a type to be defined later; it is created by issuing CREATE TYPE with no parameters except for the type name.
  • Shell types are needed as forward references when creating range types and base types, as discussed in those sections.

NOTE: https://stackoverflow.com/questions/45055852/postgres-type-field-type-is-only-a-shell

  • In short: Some types require functions that in turn require that type with is to be declared, so neither can be created - normally.
  • In order to workaround that problem, Postgres will create shell types that are pretty much placeholder just to satisfy validation.
Last edited 20 months ago by marc3932 (previous) (diff)

comment:2 by marc3932, 20 months ago

Reply from Regina Obe

The below ERROR: type "raster" is only a shell is usually not an error but a NOTICE that tells you the raster type has not been defined yet. It happens when functions using the raster type are created before the raster type is created. As long as the raster type is created before the install is complete, then it does not error, and might show as a NOTICE.

The fact it shows as an error in your case

Suggests to me, 3 possible scenarios

a) You managed to get yourself into a state where you have no raster type, which should be impossible if you are doing an upgrade of raster, unless you did some Frankenstein surgery on your raster, as people often do when they panic and see the “Raster is unpackaged” message and start deleting stuff randomly.

Like with a command

DROP TYPE raster CASCADE;

If this is the scenario you have, you’ve already destroyed any raster data you had, so best course of action is still

— uninstall postgis_raster

psql
\c rev
\i 'C:\\Program Files\\PostgreSQL\\12\\share\\contrib\\postgis-3.2\\uninstall_rtpostgis.sql'

b) You did this when you actually had no postgis_raster installed at all.

CREATE EXTENSION postgis_raster SCHEMA public VERSION unpackaged;

And then Trying to do below after a rasterless raster extension I would expect to fail with the above notice – this is what postgis_extensions_upgrade() would be doing internally

ALTER EXTENSION postgis_raster UPDATE TO "3.2.3""

This is a fake install, and can be dropped with

DROP EXTENSION postgis_raster;

but the fact you showed (raster procs from ""2.4.4 r16526"" need upgrade)" suggests this is not the case, and you are more likely facing a) or c)

c) You installed raster in a separate schema from postgis, this again I can’t imagine how this is possible, unless you started

with a postgis install from 2.4.4, using scripts instead of the extension system and then you decided to run postgis.sql in one schema and rtpostgis.sql in a separate schema.

And then you proceeded to then convert to an extensions based install.

In a regular extension install, both postgis.sql and rtpostgis.sql are packaged together, so having them somehow end up in different schemas would be I think impossible, though I would be impressed if someone could prove me wrong.

Assuming you did an extensionless install, putting raster and postgis in separate schemas

The fix (not tested) would be:

Figure out which schema you have raster installed in, and make sure you do your unpackaged install in the same schema as follows:

CREATE EXTENSION postgis_raster SCHEMA <the schema it is installed in here> VERSION unpackaged;

ALTER EXTENSION postgis_raster UPDATE;

— this part you need to do because postgis_raster is no longer relocatable, and we require both postgis and postgis_raster to reside in the same schema.

— allow you to move it

UPDATE pg_extension SET extrelocatable = true WHERE extname ='postgis_raster';

— move it

ALTER EXTENSION postgis_raster SET SCHEMA <where the postgis extension is installed>;

— at this point many of your raster functions are broken cause they are pointing at the old schema, this fixes that mess

ALTER EXTENSION postgis_raster UPDATE;

comment:3 by marc3932, 20 months ago

Thanks Regina. It makes sense now. I appreciated the detailed explanation. You are the best. Thanks again, Marcelo :)

comment:4 by robe, 20 months ago

Resolution: wontfix
Status: newclosed

@marcelo you are welcome. I'm closing this out as a wontfix cause I don't think there is anything we can do about it on the project side.

Note: See TracTickets for help on using tickets.