Skip to content
Permalink
Browse files

Postgres provider is way too chatty on debug log

  • Loading branch information
nyalldawson committed Mar 25, 2020
1 parent a061f4b commit 843277ee45a2ddd382eb303f07c7a8dfad42c3a0
@@ -2827,12 +2827,12 @@ void QgsGdalProvider::initBaseDataset()
// the min/max bounds, it would be cast to 0 by representableValue().
if ( isValid && !QgsRaster::isRepresentableValue( myNoDataValue, dataTypeFromGdal( myGdalDataType ) ) )
{
QgsDebugMsg( QStringLiteral( "GDALGetRasterNoDataValue = %1 is not representable in data type, so ignoring it" ).arg( myNoDataValue ) );
QgsDebugMsgLevel( QStringLiteral( "GDALGetRasterNoDataValue = %1 is not representable in data type, so ignoring it" ).arg( myNoDataValue ), 2 );
isValid = false;
}
if ( isValid )
{
QgsDebugMsg( QStringLiteral( "GDALGetRasterNoDataValue = %1" ).arg( myNoDataValue ) );
QgsDebugMsgLevel( QStringLiteral( "GDALGetRasterNoDataValue = %1" ).arg( myNoDataValue ), 2 );
// The no data value double may be non representable by data type, it can result
// in problems if that value is used to represent additional user defined no data
// see #3840
@@ -894,23 +894,23 @@ static void _getTitle( const QDomDocument &doc, QString &title )

if ( !nl.count() )
{
QgsDebugMsg( QStringLiteral( "unable to find title element" ) );
QgsDebugMsgLevel( QStringLiteral( "unable to find title element" ), 2 );
return;
}

QDomNode titleNode = nl.item( 0 ); // there should only be one, so zeroth element OK

if ( !titleNode.hasChildNodes() ) // if not, then there's no actual text
{
QgsDebugMsg( QStringLiteral( "unable to find title element" ) );
QgsDebugMsgLevel( QStringLiteral( "unable to find title element" ), 2 );
return;
}

QDomNode titleTextNode = titleNode.firstChild(); // should only have one child

if ( !titleTextNode.isText() )
{
QgsDebugMsg( QStringLiteral( "unable to find title element" ) );
QgsDebugMsgLevel( QStringLiteral( "unable to find title element" ), 2 );
return;
}

@@ -338,7 +338,7 @@ void QgsRendererRasterPropertiesWidget::setRendererWidget( const QString &render
{
if ( rendererEntry.widgetCreateFunction ) // Single band color data renderer e.g. has no widget
{
QgsDebugMsg( QStringLiteral( "renderer has widgetCreateFunction" ) );
QgsDebugMsgLevel( QStringLiteral( "renderer has widgetCreateFunction" ), 3 );
// Current canvas extent (used to calc min/max) in layer CRS
QgsRectangle myExtent = mMapCanvas->mapSettings().outputExtentToLayerExtent( mRasterLayer, mMapCanvas->extent() );
if ( oldWidget )
@@ -168,7 +168,7 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool reado

if ( connections.contains( conninfo ) )
{
QgsDebugMsg( QStringLiteral( "Using cached connection for %1" ).arg( conninfo ) );
QgsDebugMsgLevel( QStringLiteral( "Using cached connection for %1" ).arg( conninfo ), 2 );
connections[conninfo]->mRef++;
return connections[conninfo];
}
@@ -219,7 +219,7 @@ QgsPostgresConn::QgsPostgresConn( const QString &conninfo, bool readOnly, bool s
, mLock( QMutex::Recursive )
{

QgsDebugMsg( QStringLiteral( "New PostgreSQL connection for " ) + conninfo );
QgsDebugMsgLevel( QStringLiteral( "New PostgreSQL connection for " ) + conninfo, 2 );

// expand connectionInfo
QgsDataSourceUri uri( conninfo );
@@ -299,7 +299,7 @@ QgsPostgresConn::QgsPostgresConn( const QString &conninfo, bool readOnly, bool s
if ( !password.isEmpty() )
uri.setPassword( password );

QgsDebugMsg( "Connecting to " + uri.connectionInfo( false ) );
QgsDebugMsgLevel( "Connecting to " + uri.connectionInfo( false ), 2 );
QString connectString = uri.connectionInfo();
addDefaultTimeout( connectString );
mConn = PQconnectdb( connectString.toLocal8Bit() );
@@ -321,11 +321,11 @@ QgsPostgresConn::QgsPostgresConn( const QString &conninfo, bool readOnly, bool s
}

//set client encoding to Unicode because QString uses UTF-8 anyway
QgsDebugMsg( QStringLiteral( "setting client encoding to UNICODE" ) );
QgsDebugMsgLevel( QStringLiteral( "setting client encoding to UNICODE" ), 2 );
int errcode = PQsetClientEncoding( mConn, QStringLiteral( "UNICODE" ).toLocal8Bit() );
if ( errcode == 0 )
{
QgsDebugMsg( QStringLiteral( "encoding successfully set" ) );
QgsDebugMsgLevel( QStringLiteral( "encoding successfully set" ), 2 );
}
else if ( errcode == -1 )
{
@@ -336,7 +336,7 @@ QgsPostgresConn::QgsPostgresConn( const QString &conninfo, bool readOnly, bool s
QgsMessageLog::logMessage( tr( "undefined return value from encoding setting" ), tr( "PostGIS" ) );
}

QgsDebugMsg( QStringLiteral( "Connection to the database was successful" ) );
QgsDebugMsgLevel( QStringLiteral( "Connection to the database was successful" ), 2 );

deduceEndian();

@@ -345,15 +345,15 @@ QgsPostgresConn::QgsPostgresConn( const QString &conninfo, bool readOnly, bool s
{
/* Check to see if we have GEOS support and if not, warn the user about
the problems they will see :) */
QgsDebugMsg( QStringLiteral( "Checking for GEOS support" ) );
QgsDebugMsgLevel( QStringLiteral( "Checking for GEOS support" ), 3 );

if ( !hasGEOS() )
{
QgsMessageLog::logMessage( tr( "Your PostGIS installation has no GEOS support. Feature selection and identification will not work properly. Please install PostGIS with GEOS support (http://geos.refractions.net)" ), tr( "PostGIS" ) );
}
else
{
QgsDebugMsg( QStringLiteral( "GEOS support available!" ) );
QgsDebugMsgLevel( QStringLiteral( "GEOS support available!" ), 3 );
}
}

@@ -434,7 +434,7 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty &layerProperty, co
.arg( supportedSpatialTypes().join( ',' ) )
.arg( quotedIdentifier( schemaName ),
quotedIdentifier( viewName ) );
QgsDebugMsg( "getting column info: " + sql );
QgsDebugMsgLevel( "getting column info: " + sql, 2 );
QgsPostgresResult colRes( PQexec( sql ) );

layerProperty.pkCols.clear();
@@ -446,7 +446,6 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty &layerProperty, co
{
if ( fetchPkCandidates )
{
//QgsDebugMsg( colRes.PQgetvalue( i, 0 ) );
layerProperty.pkCols << colRes.PQgetvalue( i, 0 );
}

@@ -471,8 +470,6 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
QgsPostgresResult result;
QString query;

//QgsDebugMsg( QStringLiteral( "Entering." ) );

mLayersSupported.clear();

for ( int i = SctGeometry; i <= SctRaster; ++i )
@@ -592,7 +589,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
query += QStringLiteral( " ORDER BY 2,1,3" );


QgsDebugMsg( "getting table info from layer registries: " + query );
QgsDebugMsgLevel( "getting table info from layer registries: " + query, 2 );
result = PQexec( query, true );
// NOTE: we intentionally continue if the query fails
// (for example because PostGIS is not installed)
@@ -640,13 +637,13 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
}

#if 0
QgsDebugMsg( QStringLiteral( "%1 : %2.%3.%4: %5 %6 %7 %8" )
.arg( gtableName )
.arg( schemaName ).arg( tableName ).arg( column )
.arg( type )
.arg( srid )
.arg( relkind )
.arg( dim ) );
QgsDebugMsgLevel( QStringLiteral( "%1 : %2.%3.%4: %5 %6 %7 %8" )
.arg( gtableName )
.arg( schemaName ).arg( tableName ).arg( column )
.arg( type )
.arg( srid )
.arg( relkind )
.arg( dim ), 2 );
#endif

QgsPostgresLayerProperty layerProperty;
@@ -679,7 +676,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP

if ( isView && layerProperty.pkCols.empty() )
{
//QgsDebugMsg( QStringLiteral( "no key columns found." ) );
//QgsDebugMsgLevel( QStringLiteral( "no key columns found." ), 2 );
continue;
}

@@ -739,7 +736,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
}
}

QgsDebugMsg( "getting spatial table info from pg_catalog: " + sql );
QgsDebugMsgLevel( "getting spatial table info from pg_catalog: " + sql, 2 );

result = PQexec( sql );

@@ -768,8 +765,6 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
bool isForeignTable = relkind == QLatin1String( "f" );
QString comment = result.PQgetvalue( i, 5 ); // table comment

//QgsDebugMsg( QStringLiteral( "%1.%2.%3: %4" ).arg( schemaName ).arg( tableName ).arg( column ).arg( relkind ) );

QgsPostgresLayerProperty layerProperty;
layerProperty.types = QList<QgsWkbTypes::Type>() << QgsWkbTypes::Unknown;
layerProperty.srids = QList<int>() << std::numeric_limits<int>::min();
@@ -814,7 +809,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP

if ( isView && layerProperty.pkCols.empty() )
{
//QgsDebugMsg( QStringLiteral( "no key columns found." ) );
//QgsDebugMsgLevel( QStringLiteral( "no key columns found." ), 2 );
continue;
}

@@ -853,7 +848,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP

sql += QStringLiteral( " GROUP BY 1,2,3,4" );

QgsDebugMsg( "getting non-spatial table info: " + sql );
QgsDebugMsgLevel( "getting non-spatial table info: " + sql, 2 );

result = PQexec( sql );

@@ -876,8 +871,6 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
bool isMaterializedView = relkind == QLatin1String( "m" );
bool isForeignTable = relkind == QLatin1String( "f" );

//QgsDebugMsg( QStringLiteral( "%1.%2: %3" ).arg( schema ).arg( table ).arg( relkind ) );

QgsPostgresLayerProperty layerProperty;
layerProperty.types = QList<QgsWkbTypes::Type>() << QgsWkbTypes::NoGeometry;
layerProperty.srids = QList<int>() << std::numeric_limits<int>::min();
@@ -943,8 +936,6 @@ bool QgsPostgresConn::supportedLayers( QVector<QgsPostgresLayerProperty> &layers

layers = mLayersSupported;

//QgsDebugMsg( QStringLiteral( "Exiting." ) );

return true;
}

@@ -1031,7 +1022,7 @@ QString QgsPostgresConn::postgisVersion() const

mPostgisVersionInfo = result.PQgetvalue( 0, 0 );

QgsDebugMsg( "PostGIS version info: " + mPostgisVersionInfo );
QgsDebugMsgLevel( "PostGIS version info: " + mPostgisVersionInfo, 2 );

QStringList postgisParts = mPostgisVersionInfo.split( ' ', QString::SkipEmptyParts );

@@ -1053,8 +1044,8 @@ QString QgsPostgresConn::postgisVersion() const
{
result = PQexec( QStringLiteral( "SELECT postgis_geos_version()" ) );
mGeosAvailable = result.PQntuples() == 1 && !result.PQgetisnull( 0, 0 );
QgsDebugMsg( QStringLiteral( "geos:%1 proj:%2" )
.arg( mGeosAvailable ? result.PQgetvalue( 0, 0 ) : "none" ) );
QgsDebugMsgLevel( QStringLiteral( "geos:%1 proj:%2" )
.arg( mGeosAvailable ? result.PQgetvalue( 0, 0 ) : "none" ), 2 );
}
else
{
@@ -1070,7 +1061,7 @@ QString QgsPostgresConn::postgisVersion() const
}

// checking for topology support
QgsDebugMsg( QStringLiteral( "Checking for topology support" ) );
QgsDebugMsgLevel( QStringLiteral( "Checking for topology support" ), 2 );
mTopologyAvailable = false;
if ( mPostgisVersionMajor > 1 )
{
@@ -1095,18 +1086,18 @@ QString QgsPostgresConn::postgisVersion() const

if ( mTopologyAvailable )
{
QgsDebugMsg( QStringLiteral( "Topology support available :)" ) );
QgsDebugMsgLevel( QStringLiteral( "Topology support available :)" ), 2 );
}
else
{
QgsDebugMsg( QStringLiteral( "Topology support not available :(" ) );
QgsDebugMsgLevel( QStringLiteral( "Topology support not available :(" ), 2 );
}

mGotPostgisVersion = true;

if ( mPostgresqlVersion >= 90000 )
{
QgsDebugMsg( QStringLiteral( "Checking for pointcloud support" ) );
QgsDebugMsgLevel( QStringLiteral( "Checking for pointcloud support" ), 2 );
result = PQexec( QStringLiteral( R"(
SELECT
has_table_privilege(c.oid, 'select')
@@ -1122,11 +1113,11 @@ WHERE c.relnamespace = n.oid
if ( result.PQntuples() >= 1 && result.PQgetvalue( 0, 0 ) == QLatin1String( "t" ) )
{
mPointcloudAvailable = true;
QgsDebugMsg( QStringLiteral( "Pointcloud support available!" ) );
QgsDebugMsgLevel( QStringLiteral( "Pointcloud support available!" ), 2 );
}
}

QgsDebugMsg( QStringLiteral( "Checking for raster support" ) );
QgsDebugMsgLevel( QStringLiteral( "Checking for raster support" ), 2 );
if ( mPostgisVersionMajor >= 2 )
{
result = PQexec( QStringLiteral( R"(
@@ -1141,7 +1132,7 @@ WHERE c.relnamespace = n.oid
if ( result.PQntuples() >= 1 && result.PQgetvalue( 0, 0 ) == QLatin1String( "t" ) )
{
mRasterAvailable = true;
QgsDebugMsg( QStringLiteral( "Raster support available!" ) );
QgsDebugMsgLevel( QStringLiteral( "Raster support available!" ), 2 );
}
}

@@ -1535,7 +1526,7 @@ qint64 QgsPostgresConn::getBinaryInt( QgsPostgresResult &queryResult, int row, i
buf += QStringLiteral( "%1 " ).arg( *( unsigned char * )( p + i ), 0, 16, QLatin1Char( ' ' ) );
}

QgsDebugMsg( QStringLiteral( "int in hex:%1" ).arg( buf ) );
QgsDebugMsgLevel( QStringLiteral( "int in hex:%1" ).arg( buf ), 2 );
}
#endif

@@ -1650,12 +1641,12 @@ void QgsPostgresConn::deduceEndian()
QgsPostgresResult res( PQexec( QStringLiteral( "select regclass('pg_class')::oid" ) ) );
QString oidValue = res.PQgetvalue( 0, 0 );

QgsDebugMsg( QStringLiteral( "Creating binary cursor" ) );
QgsDebugMsgLevel( QStringLiteral( "Creating binary cursor" ), 2 );

// get the same value using a binary cursor
openCursor( QStringLiteral( "oidcursor" ), QStringLiteral( "select regclass('pg_class')::oid" ) );

QgsDebugMsg( QStringLiteral( "Fetching a record and attempting to get check endian-ness" ) );
QgsDebugMsgLevel( QStringLiteral( "Fetching a record and attempting to get check endian-ness" ), 2 );

res = PQexec( QStringLiteral( "fetch forward 1 from oidcursor" ) );

@@ -1665,8 +1656,8 @@ void QgsPostgresConn::deduceEndian()
// get the oid value from the binary cursor
qint64 oid = getBinaryInt( res, 0, 0 );

QgsDebugMsg( QStringLiteral( "Got oid of %1 from the binary cursor" ).arg( oid ) );
QgsDebugMsg( QStringLiteral( "First oid is %1" ).arg( oidValue ) );
QgsDebugMsgLevel( QStringLiteral( "Got oid of %1 from the binary cursor" ).arg( oid ), 2 );
QgsDebugMsgLevel( QStringLiteral( "First oid is %1" ).arg( oidValue ), 2 );

// compare the two oid values to determine if we need to do an endian swap
if ( oid != oidValue.toLongLong() )
@@ -1752,7 +1743,7 @@ void QgsPostgresConn::retrieveLayerTypes( QVector<QgsPostgresLayerProperty *> &l
}
}

QgsDebugMsg( "Raster srids query: " + sql );
QgsDebugMsgLevel( "Raster srids query: " + sql, 2 );
query += sql;
}
else // vectors
@@ -1812,7 +1803,7 @@ void QgsPostgresConn::retrieveLayerTypes( QVector<QgsPostgresLayerProperty *> &l

sql += " FROM " + table;

QgsDebugMsg( "Geometry types,srids and dims query: " + sql );
QgsDebugMsgLevel( "Geometry types,srids and dims query: " + sql, 2 );

query += sql;
}
@@ -2204,7 +2195,7 @@ void QgsPostgresConn::setSelectedConnection( const QString &name )

QgsDataSourceUri QgsPostgresConn::connUri( const QString &connName )
{
QgsDebugMsg( "theConnName = " + connName );
QgsDebugMsgLevel( "theConnName = " + connName, 2 );

QgsSettings settings;

0 comments on commit 843277e

Please sign in to comment.
You can’t perform that action at this time.