@@ -752,7 +752,7 @@ bool QgsPostgresProvider::loadFields()
752
752
sql = QStringLiteral ( " SELECT oid,typname,typtype,typelem,typlen FROM pg_type" );
753
753
QgsPostgresResult typeResult ( connectionRO ()->PQexec ( sql ) );
754
754
755
- QMap<int , PGTypeInfo> typeMap;
755
+ QMap<Oid , PGTypeInfo> typeMap;
756
756
for ( int i = 0 ; i < typeResult.PQntuples (); ++i )
757
757
{
758
758
PGTypeInfo typeInfo =
@@ -762,20 +762,20 @@ bool QgsPostgresProvider::loadFields()
762
762
/* typeElem = */ typeResult.PQgetvalue ( i, 3 ),
763
763
/* typeLen = */ typeResult.PQgetvalue ( i, 4 ).toInt ()
764
764
};
765
- typeMap.insert ( typeResult.PQgetvalue ( i, 0 ).toInt (), typeInfo );
765
+ typeMap.insert ( typeResult.PQgetvalue ( i, 0 ).toUInt (), typeInfo );
766
766
}
767
767
768
768
769
- QMap<int , QMap<int , QString> > fmtFieldTypeMap, descrMap, defValMap;
770
- QMap<int , QMap<int , int > > attTypeIdMap;
771
- QMap<int , QMap<int , bool > > notNullMap, uniqueMap;
769
+ QMap<Oid , QMap<int , QString> > fmtFieldTypeMap, descrMap, defValMap;
770
+ QMap<Oid , QMap<int , Oid > > attTypeIdMap;
771
+ QMap<Oid , QMap<int , bool > > notNullMap, uniqueMap;
772
772
if ( result.PQnfields () > 0 )
773
773
{
774
774
// Collect table oids
775
- QSet<int > tableoids;
775
+ QSet<Oid > tableoids;
776
776
for ( int i = 0 ; i < result.PQnfields (); i++ )
777
777
{
778
- int tableoid = result.PQftable ( i );
778
+ Oid tableoid = result.PQftable ( i );
779
779
if ( tableoid > 0 )
780
780
{
781
781
tableoids.insert ( tableoid );
@@ -785,7 +785,8 @@ bool QgsPostgresProvider::loadFields()
785
785
if ( !tableoids.isEmpty () )
786
786
{
787
787
QStringList tableoidsList;
788
- Q_FOREACH ( int tableoid, tableoids )
788
+ const auto constTableoids = tableoids;
789
+ for ( Oid tableoid : constTableoids )
789
790
{
790
791
tableoidsList.append ( QString::number ( tableoid ) );
791
792
}
@@ -804,12 +805,12 @@ bool QgsPostgresProvider::loadFields()
804
805
QgsPostgresResult fmtFieldTypeResult ( connectionRO ()->PQexec ( sql ) );
805
806
for ( int i = 0 ; i < fmtFieldTypeResult.PQntuples (); ++i )
806
807
{
807
- int attrelid = fmtFieldTypeResult.PQgetvalue ( i, 0 ).toInt ();
808
- int attnum = fmtFieldTypeResult.PQgetvalue ( i, 1 ).toInt ();
808
+ Oid attrelid = fmtFieldTypeResult.PQgetvalue ( i, 0 ).toUInt ();
809
+ int attnum = fmtFieldTypeResult.PQgetvalue ( i, 1 ).toInt (); // Int2
809
810
QString formatType = fmtFieldTypeResult.PQgetvalue ( i, 2 );
810
811
QString descr = fmtFieldTypeResult.PQgetvalue ( i, 3 );
811
812
QString defVal = fmtFieldTypeResult.PQgetvalue ( i, 4 );
812
- int attType = fmtFieldTypeResult.PQgetvalue ( i, 5 ).toInt ();
813
+ Oid attType = fmtFieldTypeResult.PQgetvalue ( i, 5 ).toUInt ();
813
814
bool attNotNull = fmtFieldTypeResult.PQgetvalue ( i, 6 ).toInt ();
814
815
bool uniqueConstraint = fmtFieldTypeResult.PQgetvalue ( i, 7 ).toInt ();
815
816
fmtFieldTypeMap[attrelid][attnum] = formatType;
@@ -830,12 +831,12 @@ bool QgsPostgresProvider::loadFields()
830
831
if ( fieldName == mGeometryColumn )
831
832
continue ;
832
833
833
- int fldtyp = result.PQftype ( i );
834
+ Oid fldtyp = result.PQftype ( i );
834
835
int fldMod = result.PQfmod ( i );
835
836
int fieldPrec = -1 ;
836
- int tableoid = result.PQftable ( i );
837
+ Oid tableoid = result.PQftable ( i );
837
838
int attnum = result.PQftablecol ( i );
838
- int atttypid = attTypeIdMap[tableoid][attnum];
839
+ Oid atttypid = attTypeIdMap[tableoid][attnum];
839
840
840
841
const PGTypeInfo &typeInfo = typeMap.value ( fldtyp );
841
842
QString fieldTypeName = typeInfo.typeName ;
@@ -3169,7 +3170,7 @@ bool QgsPostgresProvider::setSubsetString( const QString &theSQL, bool updateFea
3169
3170
*/
3170
3171
long QgsPostgresProvider::featureCount () const
3171
3172
{
3172
- int featuresCounted = mShared ->featuresCounted ();
3173
+ long featuresCounted = mShared ->featuresCounted ();
3173
3174
if ( featuresCounted >= 0 )
3174
3175
return featuresCounted;
3175
3176
0 commit comments