@@ -1233,7 +1233,8 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
1233
1233
" has_table_privilege(%1,'DELETE'),"
1234
1234
" has_any_column_privilege(%1,'UPDATE'),"
1235
1235
" %2"
1236
- " has_table_privilege(%1,'INSERT')" )
1236
+ " has_table_privilege(%1,'INSERT'),"
1237
+ " current_schema()" )
1237
1238
.arg ( quotedValue ( mQuery ) )
1238
1239
.arg ( mGeometryColumn .isNull ()
1239
1240
? QString ( " 'f'," )
@@ -1248,7 +1249,8 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
1248
1249
" has_table_privilege(%1,'DELETE'),"
1249
1250
" has_table_privilege(%1,'UPDATE'),"
1250
1251
" has_table_privilege(%1,'UPDATE'),"
1251
- " has_table_privilege(%1,'INSERT')" )
1252
+ " has_table_privilege(%1,'INSERT'),"
1253
+ " current_schema()" )
1252
1254
.arg ( quotedValue ( mQuery ) );
1253
1255
}
1254
1256
@@ -1288,6 +1290,9 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
1288
1290
mEnabledCapabilities |= QgsVectorDataProvider::AddFeatures;
1289
1291
}
1290
1292
1293
+ if ( mSchemaName .isEmpty () )
1294
+ mSchemaName = testAccess.PQgetvalue ( 0 , 4 );
1295
+
1291
1296
sql = QString ( " SELECT 1 FROM pg_class,pg_namespace WHERE "
1292
1297
" pg_class.relnamespace=pg_namespace.oid AND "
1293
1298
" pg_get_userbyid(relowner)=current_user AND "
@@ -1814,33 +1819,33 @@ QString QgsPostgresProvider::paramValue( QString fieldValue, const QString &defa
1814
1819
1815
1820
QString QgsPostgresProvider::geomParam ( int offset ) const
1816
1821
{
1817
- // TODO: retrive these at construction time
1822
+ // TODO: retrieve these at construction time
1818
1823
QString toponame;
1819
1824
long layer_id;
1820
1825
1821
1826
if ( mSpatialColType == sctTopoGeometry )
1822
1827
{
1823
1828
QString sql = QString ( " SELECT t.name, l.layer_id FROM topology.layer l, topology.topology t "
1824
- " WHERE l.topology_id = t.id AND l.schema_name=%1 "
1825
- " AND l.table_name=%2 AND l.feature_column=%3" )
1826
- .arg ( quotedValue ( mSchemaName ) )
1827
- .arg ( quotedValue ( mTableName ) )
1828
- .arg ( quotedValue ( mGeometryColumn ) );
1829
+ " WHERE l.topology_id = t.id AND l.schema_name=%1 "
1830
+ " AND l.table_name=%2 AND l.feature_column=%3" )
1831
+ .arg ( quotedValue ( mSchemaName ) )
1832
+ .arg ( quotedValue ( mTableName ) )
1833
+ .arg ( quotedValue ( mGeometryColumn ) );
1829
1834
QgsPostgresResult result = mConnectionRO ->PQexec ( sql );
1830
1835
if ( result.PQresultStatus () != PGRES_TUPLES_OK )
1831
1836
{
1832
1837
throw PGException ( result ); // we should probably not do this
1833
1838
}
1834
1839
if ( result.PQntuples () < 1 )
1835
1840
{
1836
- QgsMessageLog::logMessage ( tr ( " Could not find topology of layer %1.%2.%3" )
1837
- .arg ( quotedValue ( mSchemaName ) )
1838
- .arg ( quotedValue ( mTableName ) )
1839
- .arg ( quotedValue ( mGeometryColumn ) ),
1840
- tr ( " PostGIS" ) );
1841
+ QgsMessageLog::logMessage ( tr ( " Could not find topology of layer %1.%2.%3" )
1842
+ .arg ( quotedValue ( mSchemaName ) )
1843
+ .arg ( quotedValue ( mTableName ) )
1844
+ .arg ( quotedValue ( mGeometryColumn ) ),
1845
+ tr ( " PostGIS" ) );
1841
1846
}
1842
- toponame = result.PQgetvalue ( 0 , 0 );
1843
- layer_id = result.PQgetvalue ( 0 , 1 ).toLong ();
1847
+ toponame = result.PQgetvalue ( 0 , 0 );
1848
+ layer_id = result.PQgetvalue ( 0 , 1 ).toLong ();
1844
1849
1845
1850
}
1846
1851
@@ -1898,7 +1903,7 @@ QString QgsPostgresProvider::geomParam( int offset ) const
1898
1903
if ( mSpatialColType == sctTopoGeometry )
1899
1904
{
1900
1905
geometry += QString ( " ,%1,%2)" )
1901
- .arg ( quotedValue (toponame) )
1906
+ .arg ( quotedValue ( toponame ) )
1902
1907
.arg ( layer_id );
1903
1908
}
1904
1909
0 commit comments