Subject Re: [Firebird-Architect] the insert into t select * from t infinite loop
Author Adriano dos Santos Fernandes
Jim Starkey wrote:

>Because it doesn't work that way.
I more or less know how it works now. Please say if there is some error.

insert into t (x) select x from t

is translated to

for select x from t into :x do
insert into t (x) values (:x);

INSERT: execute before insert triggers, write the record to one
datapage, update indexes, execute after insert triggers.
write the record to one datapage: one datapage is found through
RDB$PAGES, if one is not found a new one is created and inserted in

With my approach:

The INSERTs (only from insert ... select) don't use pages that is
already in RDB$PAGES, and the new pages are not inserted in RDB$PAGES.
Some thing need to be extended to the insert in the for loop use pages
created by himself and the allocated page numbers should be stored.
After all records are writed: insert page in RDB$PAGES, update indexes,
execute after insert triggers, insert another page in RDB$PAGES, ...

I see only one design problem: how after insert triggers can work with
pages that have more than one record?
The rest is all implementable.