@@ -338,7 +338,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
338
338
339
339
for ( int i = 0 ; i < ( hasTopology () ? 3 : 2 ); i++ )
340
340
{
341
- QString sql, tableName, schemaName, columnName, typeName, sridName, gtableName;
341
+ QString sql, tableName, schemaName, columnName, typeName, sridName, gtableName, dimName ;
342
342
QgsPostgresGeometryColumnType columnType = sctGeometry;
343
343
344
344
if ( i == 0 )
@@ -348,6 +348,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
348
348
columnName = " l.f_geometry_column" ;
349
349
typeName = " upper(l.type)" ;
350
350
sridName = " l.srid" ;
351
+ dimName = " l.coord_dimension" ;
351
352
gtableName = " geometry_columns" ;
352
353
columnType = sctGeometry;
353
354
}
@@ -358,6 +359,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
358
359
columnName = " l.f_geography_column" ;
359
360
typeName = " upper(l.type)" ;
360
361
sridName = " l.srid" ;
362
+ dimName = " 2" ;
361
363
gtableName = " geography_columns" ;
362
364
columnType = sctGeography;
363
365
}
@@ -373,21 +375,22 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
373
375
" WHEN l.feature_type = 4 THEN 'GEOMETRYCOLLECTION' "
374
376
" END AS type" ;
375
377
sridName = " (SELECT srid FROM topology.topology t WHERE l.topology_id=t.id)" ;
378
+ dimName = " 2" ;
376
379
gtableName = " topology.layer" ;
377
380
columnType = sctTopoGeometry;
378
381
}
379
382
380
383
// The following query returns only tables that exist and the user has SELECT privilege on.
381
384
// Can't use regclass here because table must exist, else error occurs.
382
- sql = QString ( " SELECT %1,%2,%3,%4,%5,c.relkind"
383
- " FROM %6 l,pg_class c,pg_namespace n"
385
+ sql = QString ( " SELECT %1,%2,%3,%4,%5,%6, c.relkind"
386
+ " FROM %7 l,pg_class c,pg_namespace n"
384
387
" WHERE c.relname=%1"
385
388
" AND %2=n.nspname"
386
389
" AND n.oid=c.relnamespace"
387
390
" AND has_schema_privilege(n.nspname,'usage')"
388
391
" AND has_table_privilege('\" '||n.nspname||'\" .\" '||c.relname||'\" ','select')" // user has select privilege
389
392
)
390
- .arg ( tableName ).arg ( schemaName ).arg ( columnName ).arg ( typeName ).arg ( sridName ).arg ( gtableName );
393
+ .arg ( tableName ).arg ( schemaName ).arg ( columnName ).arg ( typeName ).arg ( sridName ).arg ( dimName ). arg ( gtableName );
391
394
392
395
if ( searchPublicOnly )
393
396
sql += " AND n.nspname='public'" ;
@@ -409,7 +412,8 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
409
412
QString column = result.PQgetvalue ( idx, 2 );
410
413
QString type = result.PQgetvalue ( idx, 3 );
411
414
QString ssrid = result.PQgetvalue ( idx, 4 );
412
- QString relkind = result.PQgetvalue ( idx, 5 );
415
+ int dim = result.PQgetvalue ( idx, 5 ).toInt ();
416
+ QString relkind = result.PQgetvalue ( idx, 6 );
413
417
bool isView = relkind == " v" || relkind == " m" ;
414
418
415
419
int srid = ssrid.isEmpty () ? INT_MIN : ssrid.toInt ();
@@ -419,12 +423,13 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
419
423
srid = INT_MIN;
420
424
}
421
425
422
- QgsDebugMsg ( QString ( " %1 : %2.%3.%4: %5 %6 %7" )
426
+ QgsDebugMsg ( QString ( " %1 : %2.%3.%4: %5 %6 %7 %8 " )
423
427
.arg ( gtableName )
424
428
.arg ( schemaName ).arg ( tableName ).arg ( column )
425
429
.arg ( type )
426
430
.arg ( srid )
427
- .arg ( relkind ) );
431
+ .arg ( relkind )
432
+ .arg ( dim ) );
428
433
429
434
layerProperty.schemaName = schemaName;
430
435
layerProperty.tableName = tableName;
@@ -433,6 +438,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
433
438
layerProperty.types = QList<QGis::WkbType>() << ( QgsPostgresConn::wkbTypeFromPostgis ( type ) );
434
439
layerProperty.srids = QList<int >() << srid;
435
440
layerProperty.sql = " " ;
441
+ layerProperty.force2d = dim == 4 ;
436
442
addColumnInfo ( layerProperty, schemaName, tableName, isView );
437
443
438
444
if ( isView && layerProperty.pkCols .empty () )
0 commit comments