Skip to content

Commit

Permalink
An attempt to fix oid overflow in regclass
Browse files Browse the repository at this point in the history
QGIS was using int to store oids, but oids are 4 byte unsigned ints.

This is an attempt to partially fix #30041
  • Loading branch information
elpaso committed Jun 12, 2019
1 parent 4ff8429 commit ad8c5a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresconn.cpp
Expand Up @@ -110,7 +110,7 @@ QString QgsPostgresResult::PQfname( int col )
return QString::fromUtf8( ::PQfname( mRes, col ) );
}

int QgsPostgresResult::PQftable( int col )
unsigned int QgsPostgresResult::PQftable( int col )
{
Q_ASSERT( mRes );
return ::PQftable( mRes, col );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresconn.h
Expand Up @@ -169,7 +169,7 @@ class QgsPostgresResult

int PQnfields();
QString PQfname( int col );
int PQftable( int col );
unsigned int PQftable( int col );
int PQftype( int col );
int PQfmod( int col );
int PQftablecol( int col );
Expand Down
8 changes: 4 additions & 4 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -749,7 +749,7 @@ bool QgsPostgresProvider::loadFields()
sql = QStringLiteral( "SELECT oid,typname,typtype,typelem,typlen FROM pg_type" );
QgsPostgresResult typeResult( connectionRO()->PQexec( sql ) );

QMap<int, PGTypeInfo> typeMap;
QMap<unsigned int, PGTypeInfo> typeMap;
for ( int i = 0; i < typeResult.PQntuples(); ++i )
{
PGTypeInfo typeInfo =
Expand All @@ -759,7 +759,7 @@ bool QgsPostgresProvider::loadFields()
/* typeElem = */ typeResult.PQgetvalue( i, 3 ),
/* typeLen = */ typeResult.PQgetvalue( i, 4 ).toInt()
};
typeMap.insert( typeResult.PQgetvalue( i, 0 ).toInt(), typeInfo );
typeMap.insert( typeResult.PQgetvalue( i, 0 ).toUInt(), typeInfo );
}


Expand All @@ -769,10 +769,10 @@ bool QgsPostgresProvider::loadFields()
if ( result.PQnfields() > 0 )
{
// Collect table oids
QSet<int> tableoids;
QSet<unsigned int> tableoids;
for ( int i = 0; i < result.PQnfields(); i++ )
{
int tableoid = result.PQftable( i );
unsigned int tableoid = result.PQftable( i );
if ( tableoid > 0 )
{
tableoids.insert( tableoid );
Expand Down

0 comments on commit ad8c5a6

Please sign in to comment.