Bug report #6889

Loading PostGIS rasters do not work

Added by Paolo Cavallini almost 12 years ago. Updated over 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Rasters
Affected QGIS version:3.6.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:16014

Description

While dropping a PostGIS raster to the canvas, everything works fine in

QGIS version 1.9.0-Master
QGIS code revision ef6da72
Compiled against Qt 4.8.2
Running against Qt 4.8.2
Compiled against GDAL/OGR 1.9.0
Running against GDAL/OGR 1.9.0
GEOS Version 3.3.3
PostgreSQL Client Version 9.1.6
SpatiaLite Version 3.1.0-RC2
QWT Version 5.2.2
PROJ.4 Version 470
QScintilla2 Version

while it is returning and error:

GDAL provider: File does not exist: PG: dbname=db_corso host=localhost user=corso
password=corso port=5432 mode=2 schema=public table=aspect

Raster layer: Provider is not valid (provider: gdal, URI: PG: dbname=db_corso
host=localhost user=corso password=corso port=5432 mode=2 schema=public table=aspect

in:

Revisione codice QGIS 489a9d5

all same libs, except for Versione QWT 6.0.0-svn

raster_drag_drop.png - raster drag and drop error (25.9 KB) Antonio Locandro, 2015-03-04 01:03 PM

History

#1 Updated by Antonio Locandro over 9 years ago

Today it happened to me, if I drag and drop from DB Manager I get the following error, if I use the add to canvas option it works fine

Using Windows 7 QGIS version 2.8.1-Wien 32 - bit

#2 Updated by Antonio Locandro over 9 years ago

here is the file

#3 Updated by Paolo Cavallini over 9 years ago

In my case (master on Debian), I can add it via D&D, not with Add to canvas.
The issue merits some deeper inspection.

#4 Updated by Salvatore Larosa over 9 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

This should be fixed in both master and release-2_8 branch.
Please reopen if necessary.

#5 Updated by Paolo Cavallini over 9 years ago

  • Resolution deleted (fixed/implemented)
  • Status changed from Closed to Reopened

Still not working here (current master on Debian sid):

GDAL provider: Cannot get GDAL raster band:
(src/providers/gdal/qgsgdalprovider.cpp : 2521 : initBaseDataset)
Raster layer: Provider is not valid (provider: gdal, URI: PG: dbname=curso host=localhost user=util password=util port=5432 mode=2 schema=gis column=rast table=clip_hdr
(src/core/raster/qgsrasterlayer.cpp : 668 : setDataProvider)

AFAICT, this happens only for rasters without a primary key.

In addition, -R raster crash QGIS (I think this is another ticket).

src/providers/gdal/qgsgdalprovider.cpp: 2334: (bandStatistics) [0ms] theStats = 1 supportedStats = 110111
src/providers/gdal/qgsgdalprovider.cpp: 2343: (bandStatistics) [0ms] Using GDAL statistics.
src/providers/gdal/qgsgdalprovider.cpp: 2359: (bandStatistics) [0ms] bApproxOK = 1
Segfault

#6 Updated by Salvatore Larosa over 9 years ago

ok, I now got it.

I am not sure if that is only due whether the primary key exist or not.
The following is a testcase with stacktrace:

-- create an empty table
CREATE TABLE public.test_raster
(
  rid integer,
  rast raster,
  CONSTRAINT enforce_height_rast CHECK (st_height(rast) = ANY (ARRAY[100, 24])),
  CONSTRAINT enforce_width_rast CHECK (st_width(rast) = ANY (ARRAY[100, 24])),
  CONSTRAINT enforce_srid_rast CHECK (st_srid(rast) = 4326)
);

-- create an empty raster
INSERT INTO test_raster(rid,rast)
VALUES(1, ST_MakeEmptyRaster( 100, 100, 0.0005, 0.0005, 1, 1, 0, 0, 4326) );

-- add primary key
ALTER TABLE test_raster ADD CONSTRAINT test_pkey PRIMARY KEY (rid);

stacktrace:

ERROR 5: GDALWarpOptions.Validate()
  nBandCount=0, no bands configured!

Program received signal SIGSEGV, Segmentation fault.
VRTWarpedDataset::CloseDependentDatasets (this=this@entry=0x2daf140) at vrtwarped.cpp:346
346            if( psWO->hSrcDS != NULL )
(gdb) bt
#0  VRTWarpedDataset::CloseDependentDatasets (this=this@entry=0x2daf140) at vrtwarped.cpp:346
#1  0x00007ffff553f634 in VRTWarpedDataset::~VRTWarpedDataset (this=0x2daf140, __in_chrg=<optimized out>) at vrtwarped.cpp:297
#2  0x00007ffff553f669 in VRTWarpedDataset::~VRTWarpedDataset (this=0x2daf140, __in_chrg=<optimized out>) at vrtwarped.cpp:298
#3  0x00007ffff555b30f in GDALClose (hDS=0x2daf140) at gdaldataset.cpp:2512
#4  0x00007fff92ea0996 in QgsGdalProvider::initBaseDataset (this=0x2da53f0)
    at /home/sam/pacchetti_gis/QGIS/src/providers/gdal/qgsgdalprovider.cpp:2526
#5  0x00007fff92e913a7 in QgsGdalProvider::QgsGdalProvider (this=0x2da53f0, uri=..., update=false)
    at /home/sam/pacchetti_gis/QGIS/src/providers/gdal/qgsgdalprovider.cpp:164
#6  0x00007fff92e9c60e in classFactory (uri=0x2d73d78) at /home/sam/pacchetti_gis/QGIS/src/providers/gdal/qgsgdalprovider.cpp:1893
#7  0x00007ffff493c8b0 in QgsProviderRegistry::provider (this=0x15fd2a0, providerKey=..., dataSource=...)
    at /home/sam/pacchetti_gis/QGIS/src/core/qgsproviderregistry.cpp:382
#8  0x00007ffff4ae126f in QgsRasterLayer::setDataProvider (this=0x2d73d40, provider=...)
    at /home/sam/pacchetti_gis/QGIS/src/core/raster/qgsrasterlayer.cpp:654
#9  0x00007ffff4addeac in QgsRasterLayer::QgsRasterLayer (this=0x2d73d40, uri=..., baseName=..., providerKey=..., loadDefaultStyleFlag=true)
    at /home/sam/pacchetti_gis/QGIS/src/core/raster/qgsrasterlayer.cpp:136
#10 0x00000000005210d7 in QgisApp::addRasterLayerPrivate (this=0x1178810, uri=..., baseName=..., providerKey=..., guiWarning=true, guiUpdate=true)
    at /home/sam/pacchetti_gis/QGIS/src/app/qgisapp.cpp:9721
#11 0x0000000000521666 in QgisApp::addRasterLayer (this=0x1178810, uri=..., baseName=..., providerKey=...)
    at /home/sam/pacchetti_gis/QGIS/src/app/qgisapp.cpp:9808
#12 0x00000000004e115f in QgisApp::dropEvent (this=0x1178810, event=0x7fffffffa690) at /home/sam/pacchetti_gis/QGIS/src/app/qgisapp.cpp:1065
#13 0x00007ffff20fc02e in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#14 0x00007ffff24c021b in QMainWindow::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#15 0x00000000004e13ec in QgisApp::event (this=0x1178810, event=0x7fffffffa690) at /home/sam/pacchetti_gis/QGIS/src/app/qgisapp.cpp:1097
#16 0x00007ffff20ac70c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#17 0x00007ffff20b1533 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#18 0x00007ffff479cb16 in QgsApplication::notify (this=0x7fffffffd890, receiver=0x13f2a30, event=0x7fffffffa690)
    at /home/sam/pacchetti_gis/QGIS/src/core/qgsapplication.cpp:253
#19 0x00007ffff2d02b5e in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#20 0x00007ffff21312c1 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4

#7 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No
  • Regression? set to No

#8 Updated by Paolo Cavallini over 6 years ago

  • Description updated (diff)

Not tested on Q3 because I can no longer load pgrasters.

#9 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Reopened to Closed
  • Resolution set to end of life

#10 Updated by Paolo Cavallini over 5 years ago

  • Status changed from Closed to Open
  • Affected QGIS version changed from master to 3.6.0
  • Resolution deleted (end of life)

#11 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

I was able to add postgis rasters from DB manager without any issue in 3.6.1/Ubuntu and Windows. Please try and leave feedback.

#12 Updated by Paolo Cavallini over 5 years ago

  • Resolution set to fixed/implemented
  • Status changed from Feedback to Closed

Confirmed, it works on QGIS 3.4.
Thanks.

Also available in: Atom PDF