Subject | Re: [firebird-support] is sql interpreted language? |
---|---|
Author | Ann W. Harrison |
Post date | 2004-10-29T14:51:50Z |
At 08:26 AM 10/29/2004, Peter wrote:
statement. So many fallacies... There is a world of possible
language manipulation between interpreted and compiled. A
language is not inherently "interpreted" or "compiled". The
handling of SQL is different in different engines, and different
for different uses of SQL in most engines. ISQL is a (feeble)
interpreter of SQL. The Firebird engine runs compiled SQL.
In Firebird, SQL statements are initially translated to a
machine-friendly format called BLR (binary language representation).
That transformation is sometimes called compilation, though it
represents only the first two phases of compilation - lexical
analysis and parsing for syntax.
The SQL->BLR transformation happens when a stored procedure or
trigger is defined, when a program is preprocessed if the program
used the embedded SQL language, when a DSQL statement is prepared,
or as the first phase of a DSQL execute immediate statement.
After the SQL-BLR transformation, a Firebird SQL statement undergoes
a second transformation, which takes it from BLR to an executable
format. This transformation includes semantic analysis - validating
the data references, determining data types, etc., access right
verification, query optimization, and the generation of an execution
structure.
The BLR->execution structure transformation happens as the second
phase of a DSQL prepare or execute immediate. It happens the first
time a stored procedure or trigger is invoked after server startup.
execution structure that moves data through a sequence of predefined
routines, yes, that's what it is. The engine does not generate
machine code, so purists will say that statements are not compiled.
I'm not nearly that purist.
using execute immediate.
Regards,
Ann
>I have been told is sql an interpreted language?My, there are a lot of experts in the world. Such a simple
statement. So many fallacies... There is a world of possible
language manipulation between interpreted and compiled. A
language is not inherently "interpreted" or "compiled". The
handling of SQL is different in different engines, and different
for different uses of SQL in most engines. ISQL is a (feeble)
interpreter of SQL. The Firebird engine runs compiled SQL.
In Firebird, SQL statements are initially translated to a
machine-friendly format called BLR (binary language representation).
That transformation is sometimes called compilation, though it
represents only the first two phases of compilation - lexical
analysis and parsing for syntax.
The SQL->BLR transformation happens when a stored procedure or
trigger is defined, when a program is preprocessed if the program
used the embedded SQL language, when a DSQL statement is prepared,
or as the first phase of a DSQL execute immediate statement.
After the SQL-BLR transformation, a Firebird SQL statement undergoes
a second transformation, which takes it from BLR to an executable
format. This transformation includes semantic analysis - validating
the data references, determining data types, etc., access right
verification, query optimization, and the generation of an execution
structure.
The BLR->execution structure transformation happens as the second
phase of a DSQL prepare or execute immediate. It happens the first
time a stored procedure or trigger is invoked after server startup.
>Is this the case and if so does this mean that the sql script is readNo and no.
>every time it is applied to a record?
>Does it mean that the sql script is read in once and converted to aCloser, but not exactly. If you interpret pcode broadly to mean an
>"pcode" (like vb used to be) format and then applied to all records
>specified?
execution structure that moves data through a sequence of predefined
routines, yes, that's what it is. The engine does not generate
machine code, so purists will say that statements are not compiled.
I'm not nearly that purist.
>Can the sql scripts in FB be "compiled" for either better performanceCan and are. If you're using DSQL, prepare your statements rather than
>or improved security?
using execute immediate.
Regards,
Ann