@@ -569,14 +569,14 @@ void QgsPostgresProvider::select( QgsAttributeList fetchAttributes, QgsRectangle
569
569
{
570
570
// Contributed by #qgis irc "creeping"
571
571
// This version actually invokes PostGIS's use of spatial indexes
572
- whereClause = QString ( " %1 && setsrid ('BOX3D(%2)'::box3d,%3) and intersects (%1,setsrid ('BOX3D(%2)'::box3d,%3))" )
572
+ whereClause = QString ( " %1 && st_setsrid ('BOX3D(%2)'::box3d,%3) and st_intersects (%1,st_setsrid ('BOX3D(%2)'::box3d,%3))" )
573
573
.arg ( quotedIdentifier ( geometryColumn ) )
574
574
.arg ( rect.asWktCoordinates () )
575
575
.arg ( srid );
576
576
}
577
577
else
578
578
{
579
- whereClause = QString ( " %1 && setsrid ('BOX3D(%2)'::box3d,%3)" )
579
+ whereClause = QString ( " %1 && st_setsrid ('BOX3D(%2)'::box3d,%3)" )
580
580
.arg ( quotedIdentifier ( geometryColumn ) )
581
581
.arg ( rect.asWktCoordinates () )
582
582
.arg ( srid );
@@ -2032,12 +2032,12 @@ bool QgsPostgresProvider::parseDomainCheckConstraint( QStringList& enumValues, c
2032
2032
enumValues.clear ();
2033
2033
2034
2034
// is it a domain type with a check constraint?
2035
- QString domainSql = QString ( " SELECT domain_name from information_schema.columns where table_name = %1 and column_name = %2" ).arg ( quotedValue ( mTableName ) ).arg ( quotedValue ( attributeName ) );
2035
+ QString domainSql = QString ( " SELECT domain_name from information_schema.columns where table_name= %1 and column_name= %2" ).arg ( quotedValue ( mTableName ) ).arg ( quotedValue ( attributeName ) );
2036
2036
Result domainResult = connectionRO->PQexec ( domainSql );
2037
2037
if ( PQresultStatus ( domainResult ) == PGRES_TUPLES_OK && PQntuples ( domainResult ) > 0 )
2038
2038
{
2039
2039
// a domain type
2040
- QString domainCheckDefinitionSql = QString ( " SELECT consrc FROM pg_constraint where conname = (SELECT constraint_name FROM information_schema.domain_constraints WHERE domain_name = %1)" ).arg ( quotedValue ( PQgetvalue ( domainResult, 0 , 0 ) ) );
2040
+ QString domainCheckDefinitionSql = QString ( " SELECT consrc FROM pg_constraint where conname= (SELECT constraint_name FROM information_schema.domain_constraints WHERE domain_name= %1)" ).arg ( quotedValue ( PQgetvalue ( domainResult, 0 , 0 ) ) );
2041
2041
Result domainCheckRes = connectionRO->PQexec ( domainCheckDefinitionSql );
2042
2042
if ( PQresultStatus ( domainCheckRes ) == PGRES_TUPLES_OK && PQntuples ( domainCheckRes ) > 0 )
2043
2043
{
@@ -2048,7 +2048,7 @@ bool QgsPostgresProvider::parseDomainCheckConstraint( QStringList& enumValues, c
2048
2048
// normally, postgresql creates that if the contstraint has been specified as 'VALUE in ('a', 'b', 'c', 'd')
2049
2049
2050
2050
// todo: ANY must occure before ARRAY
2051
- int anyPos = checkDefinition.indexOf ( " VALUE = ANY" );
2051
+ int anyPos = checkDefinition.indexOf ( " VALUE= ANY" );
2052
2052
int arrayPosition = checkDefinition.lastIndexOf ( " ARRAY[" );
2053
2053
int closingBracketPos = checkDefinition.indexOf ( " ]" , arrayPosition + 6 );
2054
2054
@@ -2274,7 +2274,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
2274
2274
if ( !geometryColumn.isNull () )
2275
2275
{
2276
2276
insert += quotedIdentifier ( geometryColumn );
2277
- values += QString ( " GeomFromWKB ($%1%2,%3)" )
2277
+ values += QString ( " st_geomfromwkb ($%1%2,%3)" )
2278
2278
.arg ( offset )
2279
2279
.arg ( connectionRW->useWkbHex () ? " " : " ::bytea" )
2280
2280
.arg ( srid );
@@ -2346,7 +2346,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
2346
2346
}
2347
2347
else if ( fit->typeName () == " geometry" )
2348
2348
{
2349
- values += QString ( " %1geomfromewkt (%2)" ).arg ( delim ).arg ( quotedValue ( it->toString () ) );
2349
+ values += QString ( " %1st_geomfromewkt (%2)" ).arg ( delim ).arg ( quotedValue ( it->toString () ) );
2350
2350
}
2351
2351
else if ( fit->typeName () == " geography" )
2352
2352
{
@@ -2362,7 +2362,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
2362
2362
// value is not unique => add parameter
2363
2363
if ( fit->typeName () == " geometry" )
2364
2364
{
2365
- values += QString ( " %1geomfromewkt ($%2)" ).arg ( delim ).arg ( defaultValues.size () + offset );
2365
+ values += QString ( " %1st_geomfromewkt ($%2)" ).arg ( delim ).arg ( defaultValues.size () + offset );
2366
2366
}
2367
2367
else if ( fit->typeName () == " geography" )
2368
2368
{
@@ -2632,7 +2632,7 @@ bool QgsPostgresProvider::changeAttributeValues( const QgsChangedAttributesMap &
2632
2632
else
2633
2633
first = false ;
2634
2634
2635
- sql += QString ( fld.typeName () == " geometry" ? " %1=geomfromewkt (%2)" :
2635
+ sql += QString ( fld.typeName () == " geometry" ? " %1=st_geomfromewkt (%2)" :
2636
2636
fld.typeName () == " geography" ? " %1=st_geographyfromewkt(%2)" :
2637
2637
" %1=%2" )
2638
2638
.arg ( quotedIdentifier ( fld.name () ) )
@@ -2695,7 +2695,7 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
2695
2695
// Start the PostGIS transaction
2696
2696
connectionRW->PQexecNR ( " BEGIN" );
2697
2697
2698
- QString update = QString ( " UPDATE %1 SET %2=GeomFromWKB ($1%3,%4) WHERE %5=$2" )
2698
+ QString update = QString ( " UPDATE %1 SET %2=st_geomfromwkb ($1%3,%4) WHERE %5=$2" )
2699
2699
.arg ( mQuery )
2700
2700
.arg ( quotedIdentifier ( geometryColumn ) )
2701
2701
.arg ( connectionRW->useWkbHex () ? " " : " ::bytea" )
@@ -2879,7 +2879,7 @@ QgsRectangle QgsPostgresProvider::extent()
2879
2879
{
2880
2880
if ( QString::fromUtf8 ( PQgetvalue ( result, 0 , 0 ) ).toInt () > 0 )
2881
2881
{
2882
- sql = QString ( " select estimated_extent (%1,%2,%3)" )
2882
+ sql = QString ( " select st_estimated_extent (%1,%2,%3)" )
2883
2883
.arg ( quotedValue ( mSchemaName ) )
2884
2884
.arg ( quotedValue ( mTableName ) )
2885
2885
.arg ( quotedValue ( geometryColumn ) );
@@ -2907,7 +2907,7 @@ QgsRectangle QgsPostgresProvider::extent()
2907
2907
2908
2908
if ( ext.isEmpty () )
2909
2909
{
2910
- sql = QString ( " select extent (%1) from %2" )
2910
+ sql = QString ( " select st_extent (%1) from %2" )
2911
2911
.arg ( quotedIdentifier ( geometryColumn ) )
2912
2912
.arg ( mQuery );
2913
2913
@@ -3125,7 +3125,7 @@ bool QgsPostgresProvider::getGeometryDetails()
3125
3125
// Didn't find what we need in the geometry_columns table, so
3126
3126
// get stuff from the relevant column instead. This may (will?)
3127
3127
// fail if there is no data in the relevant table.
3128
- sql = QString ( " select srid (%1), geometrytype (%1) from %2" )
3128
+ sql = QString ( " select st_srid (%1),st_geometrytype (%1) from %2" )
3129
3129
.arg ( quotedIdentifier ( geometryColumn ) )
3130
3130
.arg ( mQuery );
3131
3131
@@ -3154,9 +3154,9 @@ bool QgsPostgresProvider::getGeometryDetails()
3154
3154
// check to see if there is a unique geometry type
3155
3155
sql = QString ( " select distinct "
3156
3156
" case"
3157
- " when geometrytype (%1) IN ('POINT','MULTIPOINT') THEN 'POINT'"
3158
- " when geometrytype (%1) IN ('LINESTRING','MULTILINESTRING') THEN 'LINESTRING'"
3159
- " when geometrytype (%1) IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON'"
3157
+ " when st_geometrytype (%1) IN ('POINT','MULTIPOINT') THEN 'POINT'"
3158
+ " when st_geometrytype (%1) IN ('LINESTRING','MULTILINESTRING') THEN 'LINESTRING'"
3159
+ " when st_geometrytype (%1) IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON'"
3160
3160
" end "
3161
3161
" from " ).arg ( quotedIdentifier ( geometryColumn ) );
3162
3162
if ( mUseEstimatedMetadata )
0 commit comments