@@ -435,7 +435,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
435435
436436 // The following query returns only tables that exist and the user has SELECT privilege on.
437437 // Can't use regclass here because table must exist, else error occurs.
438- sql = QString ( " SELECT %1,%2,%3,%4,%5,%6,c.relkind"
438+ sql = QString ( " SELECT %1,%2,%3,%4,%5,%6,c.relkind,obj_description(c.oid) "
439439 " FROM %7 l,pg_class c,pg_namespace n"
440440 " WHERE c.relname=%1"
441441 " AND %2=n.nspname"
@@ -471,6 +471,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
471471 int dim = result.PQgetvalue ( idx, 5 ).toInt ();
472472 QString relkind = result.PQgetvalue ( idx, 6 );
473473 bool isView = relkind == " v" || relkind == " m" ;
474+ QString comment = result.PQgetvalue ( idx, 7 );
474475
475476 int srid = ssrid.isEmpty () ? INT_MIN : ssrid.toInt ();
476477 if ( majorVersion () >= 2 && srid == 0 )
@@ -498,6 +499,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
498499 layerProperty.sql = " " ;
499500 layerProperty.relKind = relkind;
500501 layerProperty.isView = isView;
502+ layerProperty.tableComment = comment;
501503 /*
502504 * force2d may get a false negative value
503505 * (dim == 2 but is not really constrained)
@@ -529,6 +531,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
529531 " ,a.attname"
530532 " ,c.relkind"
531533 " ,CASE WHEN t.typname IN ('geometry','geography','topogeometry') THEN t.typname ELSE b.typname END AS coltype"
534+ " ,obj_description(c.oid)"
532535 " FROM pg_attribute a"
533536 " JOIN pg_class c ON c.oid=a.attrelid"
534537 " JOIN pg_namespace n ON n.oid=c.relnamespace"
@@ -593,6 +596,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
593596 QString relkind = result.PQgetvalue ( i, 3 ); // relation kind
594597 QString coltype = result.PQgetvalue ( i, 4 ); // column type
595598 bool isView = relkind == " v" || relkind == " m" ;
599+ QString comment = result.PQgetvalue ( i, 5 ); // table comment
596600
597601 // QgsDebugMsg( QString( "%1.%2.%3: %4" ).arg( schemaName ).arg( tableName ).arg( column ).arg( relkind ) );
598602
@@ -603,6 +607,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
603607 layerProperty.geometryColName = column;
604608 layerProperty.relKind = relkind;
605609 layerProperty.isView = isView;
610+ layerProperty.tableComment = comment;
606611 if ( coltype == " geometry" )
607612 {
608613 layerProperty.geometryColType = sctGeometry;
@@ -644,6 +649,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
644649 " pg_class.relname"
645650 " ,pg_namespace.nspname"
646651 " ,pg_class.relkind"
652+ " ,obj_description(pg_class.oid)"
647653 " FROM "
648654 " pg_class"
649655 " ,pg_namespace"
@@ -677,6 +683,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
677683 QString schema = result.PQgetvalue ( i, 1 ); // nspname
678684 QString relkind = result.PQgetvalue ( i, 2 ); // relation kind
679685 bool isView = relkind == " v" || relkind == " m" ;
686+ QString comment = result.PQgetvalue ( i, 3 ); // table comment
680687
681688 // QgsDebugMsg( QString( "%1.%2: %3" ).arg( schema ).arg( table ).arg( relkind ) );
682689
@@ -688,6 +695,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
688695 layerProperty.geometryColType = sctNone;
689696 layerProperty.relKind = relkind;
690697 layerProperty.isView = isView;
698+ layerProperty.tableComment = comment;
691699
692700 // check if we've already added this layer in some form
693701 bool alreadyFound = false ;
0 commit comments