Skip to content
Permalink
Browse files

postgres provider: avoid quering layer_styles if it doesn't exist

  • Loading branch information
jef-n committed May 12, 2015
1 parent 12739c2 commit 1c64363ad02f31fc40081e26649b31c64c855030
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -3581,6 +3581,12 @@ QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
return "";
}

QgsPostgresResult result = conn->PQexec( "SELECT COUNT(*) FROM information_schema.tables WHERE table_name='layer_styles'" );
if ( result.PQgetvalue( 0, 0 ).toInt() == 0 )
{
return "";
}

QString selectQmlQuery = QString( "SELECT styleQML"
" FROM layer_styles"
" WHERE f_table_catalog=%1"
@@ -3594,10 +3600,11 @@ QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
.arg( QgsPostgresConn::quotedValue( dsUri.table() ) )
.arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) );

QgsPostgresResult result = conn->PQexec( selectQmlQuery, false );
result = conn->PQexec( selectQmlQuery );

QString style = result.PQntuples() == 1 ? result.PQgetvalue( 0, 0 ) : "";
conn->unref();

return style;
}

0 comments on commit 1c64363

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