mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
postgres provider: improve owner check (fixes #9844)
This commit is contained in:
parent
4afdf553e7
commit
f8f2713571
@ -894,12 +894,15 @@ bool QgsPostgresConn::openCursor( QString cursorName, QString sql )
|
||||
{
|
||||
if ( mOpenCursors++ == 0 && !mTransaction )
|
||||
{
|
||||
QgsDebugMsg( "Starting read-only transaction" );
|
||||
QgsDebugMsg( QString( "Starting read-only transaction: %1" ).arg( mPostgresqlVersion ) );
|
||||
if ( mPostgresqlVersion >= 80000 )
|
||||
PQexecNR( "BEGIN READ ONLY" );
|
||||
else
|
||||
PQexecNR( "BEGIN" );
|
||||
}
|
||||
QgsDebugMsgLevel( QString( "Binary cursor %1 for %2" ).arg( cursorName ).arg( sql ), 3 );
|
||||
return PQexecNR( QString( "DECLARE %1 BINARY CURSOR %2 FOR %3" ).
|
||||
arg( cursorName ).arg( !mTransaction ? QString() : QString( "WITH HOLD" ) ).arg( sql ) );
|
||||
arg( cursorName ).arg( !mTransaction ? "" : QString( "WITH HOLD" ) ).arg( sql ) );
|
||||
}
|
||||
|
||||
bool QgsPostgresConn::closeCursor( QString cursorName )
|
||||
|
@ -976,10 +976,11 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
|
||||
|
||||
sql = QString( "SELECT 1 FROM pg_class,pg_namespace WHERE "
|
||||
"pg_class.relnamespace=pg_namespace.oid AND "
|
||||
"pg_get_userbyid(relowner)=current_user AND "
|
||||
"%3 AND "
|
||||
"relname=%1 AND nspname=%2" )
|
||||
.arg( quotedValue( mTableName ) )
|
||||
.arg( quotedValue( mSchemaName ) );
|
||||
.arg( quotedValue( mSchemaName ) )
|
||||
.arg( connectionRO()->pgVersion() < 80100 ? "pg_get_userbyid(relowner)=current_user" : "pg_has_role(relowner,'MEMBER')" );
|
||||
testAccess = connectionRO()->PQexec( sql );
|
||||
if ( testAccess.PQresultStatus() == PGRES_TUPLES_OK && testAccess.PQntuples() == 1 )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user