Bug report #21858

QGIS crashes with PostgreSQL views

Added by Pietro Rossin 8 months ago. Updated 7 months ago.

Status:Feedback
Priority:High
Assignee:Alessandro Pasotti
Category:Data Provider/PostGIS
Affected QGIS version:3.6.1 Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:Yes Copied to github as #:29673

Description

Qgis 3.4.6 doesn't load a postgis view without an id and a geometry field (attributes only). DbManager says that the layer is invalid and cannot be loaded.

3.6.1-Noosa load the same view but crashes if I open the attribute table (crash report below).

The problem is solved if I add a counter column with

SELECT row_number() OVER () AS id,
....
...
from my_table

Pietro

Crash ID: 90077a9c9e70291cbc7f1009d8c0fddfd432457a

Stack Trace

QMutex::lock :
sourceSelectProviders :
QgsEnumerationWidgetFactory::fieldScore :
QgsEditorWidgetAutoConf::QgsEditorWidgetAutoConf :
QgsEditorWidgetAutoConf::editorWidgetSetup :
QgsEditorWidgetRegistry::findBest :
QgsAttributeTableModel::loadAttributes :
QgsAttributeTableModel::QgsAttributeTableModel :
QgsDualView::initModels :
QgsDualView::init :
QgsAttributeTableDialog::QgsAttributeTableDialog :
QgisApp::attributeTable :
QMetaObject::activate :
QAction::activate :
QMenu::actionGeometry :
QMenu::actionGeometry :
QMenu::mouseReleaseEvent :
QWidget::event :
QMenu::event :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QApplicationPrivate::sendMouseEvent :
QSizePolicy::QSizePolicy :
QSizePolicy::QSizePolicy :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QGuiApplicationPrivate::processMouseEvent :
QWindowSystemInterface::sendWindowSystemEvents :
QEventDispatcherWin32::processEvents :
CallWindowProcW :
DispatchMessageW :
QEventDispatcherWin32::processEvents :
qt_plugin_query_metadata :
QEventLoop::exec :
QMenu::exec :
QgsLayerTreeView::contextMenuEvent :
QWidget::event :
QFrame::event :
QAbstractItemView::viewportEvent :
QCoreApplicationPrivate::sendThroughObjectEventFilters :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QSizePolicy::QSizePolicy :
QSizePolicy::QSizePolicy :
QApplicationPrivate::notify_helper :
QApplication::notify :
QgsApplication::notify :
QCoreApplication::notifyInternal2 :
QGuiApplicationPrivate::processMouseEvent :
QWindowSystemInterface::sendWindowSystemEvents :
QEventDispatcherWin32::processEvents :
CallWindowProcW :
DispatchMessageW :
QEventDispatcherWin32::processEvents :
qt_plugin_query_metadata :
QEventLoop::exec :
QCoreApplication::exec :
main :
BaseThreadInitThunk :
RtlUserThreadStart :

QGIS Info
QGIS Version: 3.6.1-Noosa
QGIS code revision: 2468226bc9
Compiled against Qt: 5.11.2
Running against Qt: 5.11.2
Compiled against GDAL: 2.4.1
Running against GDAL: 2.4.1

System Info
CPU Type: x86_64
Kernel Type: winnt
Kernel Version: 10.0.17134

History

#1 Updated by Giovanni Manghi 8 months ago

  • Operating System deleted (Windows 10 pro x64)
  • Status changed from Open to Feedback
  • Subject changed from 3.6.1-Noosa and qgis 3.4.6 problems with Postgis view without id and geom field to QGIS crashes with PostgreSQL view
  • Regression? changed from No to Yes
  • Priority changed from Normal to High

Pietro Rossin wrote:

Qgis 3.4.6 doesn't load a postgis view without an id and a geometry field (attributes only). DbManager says that the layer is invalid and cannot be loaded.

3.6.1-Noosa load the same view but crashes if I open the attribute table (crash report below).

The problem is solved if I add a counter column with

SELECT row_number() OVER () AS id,
....
...
from my_table

as far as I remember it was never possible to add a view without adding a column like you say

SELECT row_number() OVER () AS id

I confirm the crash on 3.6.1 also on Linux.
When adding such views in the layers panel the table gets the warning icon "unavailable layer".

In my case QGIS 3.6.1 crashes while try opening the table or properties of such table, but if the view contains also a geom column then QGIS crashes when trying to add the layer to the project.

#2 Updated by Giovanni Manghi 8 months ago

  • Subject changed from QGIS crashes with PostgreSQL view to QGIS crashes with PostgreSQL views

#3 Updated by Alessandro Pasotti 7 months ago

  • Assignee set to Alessandro Pasotti

Also available in: Atom PDF