Re: delay of function

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Jaromír Kamler <kamler(at)centrum(dot)cz>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: delay of function
Date: 2006-03-01 23:39:09
Message-ID: 20060301233909.GA83751@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, Mar 01, 2006 at 10:44:53PM +0100, Jaromr Kamler wrote:
> There must by table with basic informations about all tables in
> data storage. So that, when someone import any spatial table,
> some function must write this basic informations inside table
> basic_metadata.

Do you have a requirement to provide metadata that's not available
via the system catalogs? Is there a reason basic_metadata can't
be a view? Are you familiar with how views work?

http://www.postgresql.org/docs/8.1/interactive/tutorial-views.html
http://www.postgresql.org/docs/8.1/interactive/sql-createview.html

> I was trying do this by trigger, like you see, but it looks like
> bad way, becouse function AddGeomColl() firstly insert record in
> geometry_columns (i fire my wrong trigger) and after that is created
> table.

What version of PostGIS are you using? Neither 1.0 nor 1.1 have
an AddGeomColl function -- do you mean AddGeometryColumn? If so
then why do you think it inserts into geometry_columns and then
creates a table? AddGeometryColumn is for adding a geometry column
to an existing table -- if you look at the function's code in
lwpostgis.sql you'll see that it executes ALTER TABLE to add a
column to an existing table, then it inserts a record into
geometry_columns. If the table doesn't exist then ALTER TABLE will
fail before the insert into geometry_columns, so if the function
reaches that insert then the table must exist. Does your system
behave differently? If so then can you provide a test case?

> I must fire some function after insert all records in new table,
> but I don't know how. Any ideas?

The database can't possibly know when you're done inserting records
so you'll have to call the function yourself with SELECT. But why
do you need to? To get the table's size? If you make basic_metadata
a view then its query could call pg_total_relation_size (or whatever).

--
Michael Fuhr

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2006-03-02 00:34:22 Re: install - OFF TOPIC
Previous Message operationsengineer1 2006-03-01 21:58:08 Re: install