Subject Re: [Firebird-Architect] Metadata cache
Author Alex Peshkov
On Saturday 16 August 2008 17:55, Dmitry Yemanov wrote:
> Dimitry Sibiryakov wrote:
> > But this verification will happen on every DML execution.
>
> I don't think so. I suppose there are many ways to set the flag during
> DDL and then check it during DML.

Yes. One possible (and appears very fast) was already described by Vlad here:

> 1. Introduce database-global atomic counter of DDL transactions. It may be
> stored in header page or in shared memory, lets decide later.
>
> 2. Every DDL transaction increments this counter at the very end stage of
> its commit.
>
> 3. Every prepared statement marked by current value of this DDL_TX counter
> at preparation time.
>
> 4. Every statement before every execution compared its private DDL_TX mark
> with current value of global DDL_TX. If private mark is less then global,
> statement must check all used metadata objects for obsolete flag. If such
> object is found, statement marked as obsolete and must be re-prepared (if
> possible) or it will raise error on execution. If such object was not found
> statement marked with new value of DDL_TX and started its execution.

You see - minimum overhead on both ends: DDL transaction modifies single
global counter, request before execution performs single comparison, w/o need
in any locks during it.