[Qgis-user] Qgis, postgis and updateable views

Ricardo Filipe Soares Garcia da ricardo.garcia.silva at gmail.com
Sat Oct 24 04:55:23 PDT 2009


Hello list
I am using Qgis 1.3.0 compiled from the release tarball on Kubuntu 9.04.

I am trying to create an updateable postgis view that will be updated
through Qgis.

I have a postgis DB with spatial and non-spatial tables. I'm using a
view to abstract the relational connections between several tables and
a spatial table and present the user (me) with a flat-file-like type
of visualization through Qgis, so that I can see the real values of my
spatial data instead of a bunch of foreign keys. This visualization is
working fine, I have created the postgis view and can use it inside
Qgis.

Now I'd like to be able to use Qgis to insert and update my view and
have postgresql do the real inserting and updating to my tables in the
background. For this purpose I am creating some postgresql rules as in
shown in [1] and [2]. So far I have succeeded in creating the UPDATE
rule, which is working really nice and I think I have successfully
created the INSERT rule as well, but I'm unable to test it due to Qgis
crashing.

My problem lies with the creation of new geometries.
So far Qgis is crashing with the 'Segmentation fault' message when I
try to create a new polygon on the view layer:
To replicate the crash:
    1 - load postgis layer (this layer is a postgis view, definded
with SQL code in [3]) in Qgis
    2 - toggle the edit mode to 'on'
    3 - select the 'capture polygon' tool
    4 - click anywhere on the map canvas
    5 - ugly crash (segmentation fault reported on the console)

Is it not possible to draw a new feature on a view layer? can someone
replicate this behaviour? If not, it really should because the insert
rule on postgres's side will (hopefully and most likely) accept that.
Please note than I can update an already existing feature (for example
moving some vertices around) and it works ok.

Thanks in advance

[1] - http://www.postgresonline.com/journal/index.php?/archives/11-Database-Abstraction-with-Updateable-Views.html
[2] - http://www.postgresql.org/docs/8.1/interactive/rules-update.html
[3] - SQL code follows:

CREATE OR REPLACE VIEW salasp1 AS
	SELECT s.sa_gid, s.the_geom,
		e.sigla AS edificio, p.numero AS piso,
		s.nome AS sala, t.tipo, f.funcionalidade,
		d.sigla AS sigla_dep_servico, d.nome AS dep_servico,
                s.descricao, s.lugares, s.tomadas, s.telefones
	FROM sala s, tipo t, funcionalidade f, piso p, edificio e, deptoservico d
	WHERE p.numero=1 AND p.pi_gid=s.pi_gid
		AND s.ti_id=t.ti_id AND s.fu_id=f.fu_id
		AND e.sigla='C8' AND d.dep_id=s.depserv_id;


-- 
___________________________ ___ __
Ricardo Garcia Silva



More information about the Qgis-user mailing list