Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove context limit for stored procedures/functions/triggers as well as for user SQL queries [CORE809] #1195

Open
firebird-automations opened this issue Jan 23, 2006 · 21 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: marcgeldon (marcgeldon)

Is duplicated by CORE2694

Votes: 12

SFID: 1412839#⁠
Submitted By: marcgeldon

Have a look at the summary. If a stored procedure / trigger is too complex, you'll get the following error:

Invalid token. Invalid request BLR at offset xxxx.
"context not defined (BLR error)"
or
"Too many Contexts of Relation/Procedure/Views. Maximum allowed is 256"

Every table/procedure reference means a "context" and their total count is limited by 256 contexts. Removing or extending this limit would allow more complex PSQL code to be developed.

@firebird-automations
Copy link
Collaborator Author

Commented by: Alice F. Bird (firebirds)

Date: 2006-01-25 13:29
Sender: dimitr
Logged In: YES
user_id=61270

Size limit for SPs/triggers and limit of available record
source contexts are two different ones. However, I agree
that both should be removed/extended.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

issuetype: New Feature [ 2 ] => Improvement [ 4 ]

assignee: Dmitry Yemanov [ dimitr ]

SF_ID: 1412839 =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Component: Engine [ 10000 ]

SF_ID: 1412839 =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

assignee: Dmitry Yemanov [ dimitr ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 10833 ] => Firebird [ 15269 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

Link: This issue is duplicated by CORE2694 [ CORE2694 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

description: SFID: 1412839#⁠
Submitted By: marcgeldon

Have a look at the summary. If a stored procedure /
trigger is too long, you'll get the following error:

Invalid token. Invalid request BLR at offset xxxx.
context not defined (BLR error).

Best wishes,

Marc Geldon

=>

SFID: 1412839#⁠
Submitted By: marcgeldon

Have a look at the summary. If a stored procedure / trigger is too complex, you'll get the following error:

Invalid token. Invalid request BLR at offset xxxx.
"context not defined (BLR error)"
or
"Too many Contexts of Relation/Procedure/Views. Maximum allowed is 256"

Every table/procedure reference means a "context" and their total count is limited by 256 contexts. Removing or extending this limit would allow more complex PSQL code to be developed.

summary: Remove limit for size of stored procedures / triggers => Remove context limit for stored procedures / triggers

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 4.0 Alpha 1 [ 10731 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @abzalov

Due to the below issuies are closed, does it mean that in Firebird v3.0 context limit for stored procedures/triggers are removed or extended?
- CORE4684
- CORE4710

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

No, v3.0 has the same limit of 256 contexts. However, it has some minor improvements, in particular it generates less contexts for N-way unions.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 4.0 Beta 1 [ 10750 ]

Fix Version: 4.0 Alpha 1 [ 10731 ] =>

@firebird-automations
Copy link
Collaborator Author

Commented by: Volker Rehn (vr2_s18)

This can close a gap and provide a method to bulk load within user/attachment/transaction contexts. A simple example would be an insert script within a dynamically generated and executed execute block. This does not have the restrictions of external tables. It won't be as fast as external tables, but those are just too restrictive in many cases.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 4.0 Beta 1 [ 10750 ] =>

@nLeonardt95
Copy link

nLeonardt95 commented Nov 24, 2023

Why is there a limit for update/insert/delete, but I can set as many stored procedures as I want?
Or is there a limit there too?
I tried to create a stored procedure with several updates and I was able to execute the stored procedure within a execute block more than 1000 times.

@dyemanov
Copy link
Member

The limit applies to the BLR (byte code) where every table reference is encoded with a single-byte number. Thus the limit is static and does not affect how many times the procedure is executed.

@nLeonardt95
Copy link

And how is it possible to execute an unlimited number of stored procedures within an execute block?

@dyemanov
Copy link
Member

  1. BLR is per-procedure, so one procedure call cannot have more than 255 table references, but many different calls do not share this limit.
  2. EXECUTE PROCEDURE does not create a context, so EXECUTE BLOCK may have lots of them. However, SELECT FROM PROCEDURE creates a context, so your EXECUTE BLOCK cannot have more than 255 SELECTs from procedures.

@livius2
Copy link

livius2 commented Jan 20, 2024

Is this really hard to have blr with 2, 3, 4 bytes context number instead of current one? Is Blr versioned?

@dyemanov
Copy link
Member

Thanks for reminder, I believe we should schedule this improvement for v6.

This shouldn't be very hard, I've attempted it once. BLR is indeed versioned and we may just raise the BLR version number instead of duplicating all BLR verbs that contain stream number(s). But I'd prefer to use new BLR version only if the code really overflows the 255 limit. This would make the usual code backward compatible and down-gradable if required.

@dyemanov dyemanov changed the title Remove context limit for stored procedures / triggers [CORE809] Remove context limit for stored procedures/functions/triggers as well as for urse SQL queries [CORE809] Jan 21, 2024
@dyemanov dyemanov changed the title Remove context limit for stored procedures/functions/triggers as well as for urse SQL queries [CORE809] Remove context limit for stored procedures/functions/triggers as well as for user SQL queries [CORE809] Jan 21, 2024
@livius2
Copy link

livius2 commented Jan 21, 2024

Yes, backward compatibility is an important consideration.
I'm not sure how challenging it will be to check for a 256 context overflow at the beginning of BLR generating.
However, if it's a difficult task, you could introduce a flag in, for example, RDB$Database, allowing users to switch from the old to the new system.
All newly compiled objects would then use the new version of BLR.
This could be implemented through a command or even during the restore process with a switch.
Please consider my comment as just a suggestion; the more perspectives we have, the better, even if some ideas might not be ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants