What is BLR?


BLR stands for Binary Language Representation. All SQL queries are translated from SQL into BLR before execution. When you create or alter a stored procedure, trigger, view or computed column, Firebird compiles the source code and stores it in such compiled way in the system tables. It also stores the original SQL you used, but it never actually uses it. Later when a stored procedure is executed Firebird simply executes that binary code without a need to compile it once again. Having precompiled BLR also reduces the dependencies on the database objects. For example, imagine you have tables:

CREATE TABLE t1 ( a integer, b integer );
CREATE TABLE t2 ( c integer );

and the following query in a stored procedure:

SELECT a, b
FROM t1
JOIN t2 ON t1.a = t2.c;

Later you can easily add a column named B to table T2, and stored procedure would still work even though the query itself would throw an error:

Ambiguous field name between table T1 and table T2
B

The reason that procedure still works it because SQL isn't processed anymore and BLR contains reference to field B from table T1.


Do you find this FAQ incorrect or incomplete? Please e-mail us what needs to be changed. To ensure quality, each change is checked by our editors (and often tested on live Firebird databases), before it enters the main FAQ database. If you desire so, the changes will be credited to your name. To learn more, visit our add content page.



All contents are copyright © 2007-2024 FirebirdFAQ.org unless otherwise stated in the text.


Links   Firebird   News   FlameRobin   Powered by FB: Home Inventory   Euchre  
Add content   About  

Categories
 Newbies
 SQL
 Installation and setup
 Backup and restore
 Performance
 Security
 Connectivity and API
 HOWTOs
 Errors and error codes
 Miscellaneous