You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Ян Программист <we...@gmail.com> on 2010/04/23 16:55:48 UTC

SQL processing

What classes are responsible for producing logical model from SQL? I want to
understand how to code the equivalent of, say, following SQL:

select grasp, result, density from REDUNDANT;

to directly force necessary execution mechanisms, instead of doing SQL sting
pre-processing. John

Re: SQL processing

Posted by Bryan Pendleton <bp...@gmail.com>.
?? ??????????? wrote:
> What classes are responsible for producing logical model from SQL? I 
> want to understand how to code the equivalent of, say, following SQL:
> 
> select grasp, result, density from REDUNDANT;
> 
> to directly force necessary execution mechanisms, instead of doing SQL 
> sting pre-processing. John  

I think this would be a fairly tricky thing to do. The execution API
code is quite tightly bound up with the parser and compiler. Internally,
when Derby code occasionally wants to execute some SQL during the
processing of other work (e.g., for accessing system catalogs), the
the technique even then is to generate, parse, compile, and execute
a string of SQL, rather than trying to program directly against the
execution classes.

If you wanted to understand the execution classes and how they work,
I think that a good start is to read the code in impl.sql.execute,
and then to have a look at how the code in impl.sql.compile constructs
those execution-time objects.

For the particular query you mention above, you'll want to look at
ProjectRestrictResultSet and how it works together with TableScanResultSet
and the ScanController class.

You should know ahead of time that this is quite complicated code; for
example, the projection logic (extracting the values of 'grasp', 'result',
and 'density' from the current row) is handled by generating Java
bytecode on-the-fly during compilation and then invoking that byte code
at execution time.

thanks,

bryan