[OpenSER-Devel] Defining MySQL foreign key constraint

Dan Pascu dan at ag-projects.com
Mon Jul 16 14:16:40 CEST 2007


On Monday 16 July 2007, Henning Westerholt wrote:
> Hello Mircea,
>
> i've changed the mysql engine specification according your suggestions.
>
> Regarding the TIMESTAMP:
> AFAIK postgres don't provide the ON UPDATE clause. You could work
> around this with a trigger, but for dbtext this is not possible. So i

You do not need to specify ON UPDATE. If you don't, it will assume you did 
and do the update automatically.

Thus a column like this:

last_modified timestamp not null

will assume both DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP 
and will automagically set the column to CURRENT_TIMESTAMP on inserts and 
updates if you use mysql, while it will still work with other databases 
that have such a column type, but without the magic updates.

> guess this is the reason that the logic to update the timestamp is
> located in openser, and not in the database.

While it can't be applied to the core openser tables that need to work 
with all supported databases, nevertheless it can be useful to people 
trying to write custom modules that do not necessarily support all 
database types, or for custom tables that are used directly from the 
script using AVP database query operations.

So I believe it can be an useful addition even if it isn't used by the 
main tables.

-- 
Dan



More information about the Devel mailing list