Skip to content

Commit 4a507e4

Browse files
author
jef
committedMay 5, 2010
minor pg provider fix: oid==0 is invalid
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13424 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ bool QgsPostgresProvider::loadFields()
853853
QString fieldElem = QString::fromUtf8( PQgetvalue( oidResult, 0, 2 ) );
854854
int fieldSize = QString::fromUtf8( PQgetvalue( oidResult, 0, 3 ) ).toInt();
855855

856-
if ( tableoid >= 0 )
856+
if ( tableoid > 0 )
857857
{
858858
sql = QString( "SELECT attnum FROM pg_attribute WHERE attrelid=%1 AND attname=%2" )
859859
.arg( tableoid ).arg( quotedValue( fieldName ) );
@@ -2940,7 +2940,7 @@ bool QgsPostgresProvider::deduceEndian()
29402940
for ( i = 0; i < PQnfields( res ); i++ )
29412941
{
29422942
int tableoid = PQftable( res, i );
2943-
if ( tableoid >= 0 )
2943+
if ( tableoid > 0 )
29442944
{
29452945
oidValue = QString::number( tableoid );
29462946
break;
@@ -3016,31 +3016,31 @@ bool QgsPostgresProvider::getGeometryDetails()
30163016
Result result = connectionRO->PQexec( sql );
30173017
if ( PGRES_TUPLES_OK == PQresultStatus( result ) )
30183018
{
3019-
Oid tableOid = PQftable( result, 0 );
3019+
Oid tableoid = PQftable( result, 0 );
30203020
int column = PQftablecol( result, 0 );
30213021

30223022
result = connectionRO->PQexec( sql );
3023-
if ( tableOid >= 0 && PGRES_TUPLES_OK == PQresultStatus( result ) )
3023+
if ( tableoid > 0 && PGRES_TUPLES_OK == PQresultStatus( result ) )
30243024
{
3025-
sql = QString( "SELECT pg_namespace.nspname,pg_class.relname FROM pg_class,pg_namespace WHERE pg_class.relnamespace=pg_namespace.oid AND pg_class.oid=%1" ).arg( tableOid );
3025+
sql = QString( "SELECT pg_namespace.nspname,pg_class.relname FROM pg_class,pg_namespace WHERE pg_class.relnamespace=pg_namespace.oid AND pg_class.oid=%1" ).arg( tableoid );
30263026
result = connectionRO->PQexec( sql );
30273027

30283028
if ( PGRES_TUPLES_OK == PQresultStatus( result ) && 1 == PQntuples( result ) )
30293029
{
30303030
schemaName = QString::fromUtf8( PQgetvalue( result, 0, 0 ) );
30313031
tableName = QString::fromUtf8( PQgetvalue( result, 0, 1 ) );
30323032

3033-
sql = QString( "SELECT attname FROM pg_attribute WHERE attrelid=%1 AND attnum=%2" ).arg( tableOid ).arg( column );
3033+
sql = QString( "SELECT attname FROM pg_attribute WHERE attrelid=%1 AND attnum=%2" ).arg( tableoid ).arg( column );
30343034
result = connectionRO->PQexec( sql );
30353035
if ( PGRES_TUPLES_OK == PQresultStatus( result ) && 1 == PQntuples( result ) )
30363036
{
30373037
geomCol = QString::fromUtf8( PQgetvalue( result, 0, 0 ) );
30383038
}
3039-
else
3040-
{
3041-
schemaName = mSchemaName;
3042-
tableName = mTableName;
3043-
}
3039+
else
3040+
{
3041+
schemaName = mSchemaName;
3042+
tableName = mTableName;
3043+
}
30443044
}
30453045
}
30463046
}

0 commit comments

Comments
 (0)
Please sign in to comment.