Subject Re: [firebird-support] Too many Contexts ... Maximum allowed is 127.
Author Dmitry Yemanov
Valdir Stiebe Junior - Dype Soluções wrote:
> Some questions regarding this error: Too many Contexts of
> Relation/Procedure/Views. Maximum allowed is 127.
> 1. It is possible to raise the maximum contexts allowed (via config file
> or recompiling)?


> 2. What is a context?

A reference to a table or a selectable stored procedure. Additionally,
every union and aggregation (don't remember about DISTINCT) also
introduces a context.

> 2.1. When it is created?

When the appropriate query element is being parsed and compiled.

> 2.2. When it is released?

When the query is released.

> 2.3. Why only 127 are allowed?

It's an internal BLR limitation.

> 3. What are the alternatives for what I am trying to do (follow a little
> explanation)?

1) Simplify the query
2) Put some its parts into a stored procedure

When many complex nested views are involved, you're in trouble, because
all those views are being expanded and their parts are compiled along
with the parent query. This doesn't happen for stored procedures as they
have independent context scopes.