[Qgis-developer] Postgis Live historisation

Mayeul Kauffmann mayeul.kauffmann at free.fr
Fri Sep 2 16:44:07 EDT 2011


Hi,
I am trying to use Postgis Live historisation from QGIS, following:
http://www.kappasys.ch/pgtools/pghistory/#toc8

I ran into several problems.
------------------------
Main one is:
After initial import of dataset, the first modification to each single
feature does not add the archive date to it (hence the view does not
filter it). Subsequent modification of a feature which has been modified
at least once are correctly logged and the archive date is correctly
inserted.
Here is what I do:

1. Create data structure with:
 shp2pgsql -p -c -I points_test.shp | psql)
2. initialise historisation
SELECT add_history('public'::text, 'points_test'::text,
'public_view'::text,   'points_test_view'::text, true);
3. Load data
 shp2pgsql -a points_tests.shp public_view.points_test_view
4. Modify a feature in QGIS

Swapping steps 2 & 3 give same results.
As a workaround, I was thinking of making a simple "update" (updating a
field by setting it to its own value) and then deleting unnecessary rows
just after step 3, but I cold not find a way to have the desired effect.

------------------------
2nd problem is related to date attribute: I have dates as attributes to
my tables. The perl code seems to assume that if it's not a text, it's a
numeric and posgres complains about the trigger trying to insert a
numeric into a date field.
My workaround is to use only text field instead of date fields; I can
live with this.
-----------------------
Some other problems are related to documentation.

I had to find out that the following is necessary:


-- DROP TYPE IF EXISTS  change_type CASCADE;
CREATE TYPE change_type AS  ENUM ('insert', 'update', 'delete');
CREATE SCHEMA public_view AUTHORIZATION 
The doc says:
myaccount;add_history('name_schema','name_table','name_schema_view','name_view')
but looking at the code shows that a new (boolean) parameter was addded
at the end.

Finally, last problem: I could not simply load the functions from the
shell with:
psql
-f ~/postgis/insert_timegis_trigger_function.sql
It complained about an error near the end of the script, near <<>>
(double quotes with nothing in it?!)
I had to open the query in pgadmin3 to run it.

Thanks for any hint!
Mayeul



More information about the Qgis-developer mailing list