[Qgis-developer] Postgres provider checks queries and refuses CTE
Vincent Picavet
vincent.ml at oslandia.com
Tue Jul 10 08:10:23 PDT 2012
Hi,
The postgres provider apparently does a check on the input query and only
tolerates queries beginning with "SELECT".
The more general SQL query form allows for queries not beginning with select,
but still being valid, as it is the case for CTEs. The only way to have qgis
load them is to wrap CTEs inside a select, which is not really nice.
Example.
This won't load in qgis :
with points as (select gid, st_makepoint(random() * 10, random() * 10) as
the_geom from generate_series(1, 100) as gid) select * from points
But this will :
select * from (with points as (select gid, st_makepoint(random() * 10,
random() * 10) as the_geom from generate_series(1, 100) as gid) select * from
points) as foo
This is also the case for other kind of queries like UPDATE... RETURNING,
which should be valid but don't conform to the filter.
Is the filter useful anyway, since there are so many ways to write non-valid
queries ?
So the question is : do we get rid of the SELECT filter in postgres provider ?
Those in favor of keeping it raise your hands and arguments now, or I think
we'd better drop it...
Vincent
More information about the Qgis-developer
mailing list